Repository navigation
fix(webui): read the ports status as the API sends it, and use the web alert - #3695
Merged
Merged
Conversation
…b alert
`plugin-ports.vue` disagreed with the ports plugin on two counts. Both were
verified against a live `/api/4/ports` response rather than inferred.
1. URL rows were decorated by `getPortDecoration`. `getWebDecoration` was
defined in the same file and never called.
The port form compares `status` against an rtt threshold, but a URL's
status is an HTTP code or the string 'Error'. With the default
`rtt_warning: null` every URL therefore fell through to "ok": an
unreachable URL rendered green while the TUI rendered it CRITICAL. With a
threshold configured it was still wrong the other way -- `200 > 1` is true,
so a healthy URL rendered "warning", and a 404 rendered "warning" instead
of "critical".
2. The status text compared against the strings 'null', 'false' and 'true'.
The API sends real JSON values. Captured from a running server:
{"description": "ClosedPort", "status": false, "rtt_warning": null, ...}
{"description": "UnreachableWeb", "status": "Error", "elapsed": 0, ...}
`false == 'false'` is `0 == NaN` in JavaScript, so none of the three
branches could ever match. A closed or timed-out port fell through to
`false * 1000` and displayed "0ms" -- which reads as an instant, perfect
response for a port that is down. "Scanning" and "Timeout" never rendered
at all, and the 'true' branch was doubly dead: the scanner only ever sets
`status` to None, a float, or False.
Both now mirror the plugin, which is the authority: `set_status_if_host`,
`set_status_if_url` and `get_conds_if_url`. The URL branch falls through to
the raw status string as `set_status_if_url` does, rather than special-casing
'Error'.
Evidence, since the WebUI has no JS test runner -- counted in the rebuilt
bundle:
getPortDecoration 3 -> 2 (definition + two call sites -> + one)
getWebDecoration 1 -> 2 (definition only -> definition + call site)
"null" literals 4 -> 2
"false" literals 4 -> 3
`npx eslint` on the component: 0 errors (the one `vue/require-default-prop`
warning is on the untouched `props` block and predates this change).
ntdatt812
force-pushed
the
fix/webui-ports-status
branch
from
August 29, 2026 08:12
61b6649 to
a8ef0b6
Compare
Contributor
Author
|
Reworked per your note on #3699: rebased onto current |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
plugin-ports.vuedisagrees with the ports plugin on two counts. I verified both against a live/api/4/portsresponse rather than inferring them from the source.Ground truth
Ran a local server against a closed port and an unreachable URL:
[{"host":"127.0.0.1","port":"1","description":"ClosedPort","status":false,"rtt_warning":null,...}, {"url":"http://127.0.0.1:1/nope","description":"UnreachableWeb","status":"Error","elapsed":0,"rtt_warning":null,...}]statusis a JSON boolean / number / string.rtt_warningdefaults to null. Both bugs fall out of that.1. URL rows used the port alert;
getWebDecorationwas dead codeThe template called
getPortDecoration(port)for both branches.getWebDecorationis defined in the same file and never called.getPortDecorationcomparesstatusagainst an rtt threshold, but a URL's status is an HTTP code or'Error':rtt_warningstatus: "Error"(unreachable)null(default)status: 404null(default)status: 4041status: 200(healthy)1The default row is the bad one:
200 > 1and404 > 1are both true, but with no threshold configured everything falls through to"ok"— an unreachable URL renders green.2. The status text compared against strings
false == 'false'is0 == NaNin JavaScript — none of the three branches can ever match. A closed or timed-out port falls through tofalse * 1000and renders "0ms", which reads as an instant, perfect response for a port that is down. Scanning renders "0ms" too.The
'true'branch is dead twice over:_port_scan_tcp/ the ping path only ever assignNone, a float, orFalse— neverTrue.Note the file already knew this:
getPortDecorationright below compares=== nulland=== falseagainst the real values. Only the template was written against strings.The fix
Both branches now mirror the plugin, which is the authority —
set_status_if_host,set_status_if_url,get_conds_if_url. The URL branch falls through to the raw status string exactly asset_status_if_urldoes, instead of special-casing'Error'.I checked the severity ordering too, since that is what bit #3690:
get_default_ret_valueresolvesCRITICAL → WARNING → CAREFUL, andgetWebDecoration's existing order is equivalent for these mutually-exclusive conditions, so it needed no change — only calling.Evidence
The WebUI has no JS test runner, so the proof is the rebuilt bundle:
getPortDecorationgetWebDecoration"null"literals"false"literals3 → 2 and 1 → 2 is definition-plus-two-call-sites becoming definition-plus-one, and definition-only becoming definition-plus-call-site.
glances.js686883 → 686888 bytes; only the component and the bundle changed.npx eslinton the component: 0 errors. The singlevue/require-default-propwarning is on the untouchedpropsblock and predates this change.