Commit 8300eb8
authored
fix(plugin): read the OS version branch from the updater config on OSTree hosts (#2084)
## Summary
On Unraid OS 8 (Fedora/OSTree hosts) the Connect plugin always reported
the OS version branch as `stable`, because there is no OS plugin to read
a `CATEGORY` from. `ServerState::osVersionBranch` and the `unraidcheck`
release query now use the branch of the installed release that Core
records in the updater config.
## Why This Exists
Unraid 7 derives the branch from the `CATEGORY` attribute of the
installed OS plugin
(`/usr/local/emhttp/plugins/unRAIDServer/unRAIDServer.plg`, also linked
at `/var/log/plugins/unRAIDServer.plg`). Unraid OS 8 has no OS plugin:
neither file exists on an OSTree host (detectable by
`/run/ostree-booted`), so both call sites fell through to their `stable`
default even on a `preview` or `next` install.
Core (unraid/core#1221) records the branch of the installed release in
`/boot/config/os-update.json` as the top-level string key `branch`; the
image default `/etc/unraid/os-update.json` may exist as a read-only
fallback.
## Resolution
- Add one shared helper, `OsRelease`
(`plugins/dynamix.my.servers/include/os-release.php`), required by both
`state.php` and `UnraidCheck.php`.
- `OsRelease::branch()`: when an `unRAIDServer.plg` exists, keep using
`plugin category` (the webGui `plugin()` helper, or the CLI when the
helper is not loaded). Otherwise, when `/run/ostree-booted` exists, read
`branch` from `/boot/config/os-update.json`, then
`/etc/unraid/os-update.json`. Only values matching
`/^[a-z0-9][a-z0-9_-]{0,31}$/` are accepted; everything else, including
missing or malformed JSON, resolves to `stable` without throwing.
- `OsRelease::version()`: reads `version` from `/etc/unraid-version`
(ini-style, e.g. `version="8.0.0-preview.3"`).
- `state.php`: `osVersionBranch` uses `OsRelease::branch()`.
- `UnraidCheck.php`: the `branch` query parameter uses
`OsRelease::branch()`; `current_version` falls back to
`OsRelease::version()` before `var.ini` when there is no OS plugin
version (OS 8).
## Behavior Changes
- Unraid 7: unchanged. The branch still comes from the installed OS
plugin's `CATEGORY`; `current_version` still prefers the patcher
version, then the plugin version.
- Unraid OS 8: `osVersionBranch` and the `unraidcheck` `branch`
parameter reflect the installed release branch from
`/boot/config/os-update.json` (or the image default), and
`current_version` comes from `/etc/unraid-version`. Hosts with no
readable or valid branch still report `stable`.
## Verification
- The plugin package has no phpunit harness; its PHP tests are
standalone php-cli scripts run from `pnpm test` (CI `test-api` job
installs `php-cli` and runs `cd plugin && pnpm test`). Added
`plugin/tests/test-os-release.php` (+ `.sh` wrapper) in the same pattern
as `test-extractor` and wired it into `pnpm --filter
@unraid/connect-plugin test` as `test:os-release`.
- `bash plugin/tests/test-os-release.sh` — 21 passed, 0 failed (Unraid 7
category path, OSTree boot/etc config precedence, malformed JSON,
non-string/missing key, invalid values, trimming, 32-char limit,
`/etc/unraid-version` parsing).
- `php -l` on the three PHP files — no syntax errors.
- `git diff --check` — passed.
## Review Notes
The forecast and final AI-review receipts are committed on the branch.
The commits were made with the JS lint-staged hook skipped because it
has no rule for PHP, JSON, or shell files and the worktree has no
`node_modules`. No merge or auto-merge was performed.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Improvements**
* Improved detection of the installed Unraid OS branch across standard
and OSTree-based systems.
* Improved current-version reporting by using the installed OS version
when other version information is unavailable.
* Update checks now use the detected OS branch, improving accuracy for
non-stable release channels.
* **Bug Fixes**
* Added safer handling for missing, malformed, or invalid OS release
information, with a stable branch fallback.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent d061525 commit 8300eb8
7 files changed
Lines changed: 252 additions & 4 deletions
File tree
- .limetech/ai-review-markers
- plugin
- source/dynamix.unraid.net/usr/local/emhttp/plugins
- dynamix.my.servers/include
- dynamix.plugin.manager/include
- tests
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
Lines changed: 108 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
112 | 113 | | |
113 | 114 | | |
114 | 115 | | |
115 | | - | |
| 116 | + | |
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
| |||
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
165 | 166 | | |
166 | 167 | | |
167 | 168 | | |
168 | | - | |
| 169 | + | |
169 | 170 | | |
170 | 171 | | |
171 | 172 | | |
| |||
176 | 177 | | |
177 | 178 | | |
178 | 179 | | |
179 | | - | |
| 180 | + | |
180 | 181 | | |
181 | 182 | | |
182 | 183 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
0 commit comments