Repository navigation
fix: close the defects a seventh audit found - #8
Merged
Merged
Conversation
A seventh audit of the gateway, the engine, the dashboard and the docs found ten defects; each fix below has a test that fails without it. The gateway key hook compared `request.url` against `/v1/`. The router splits the raw target on `/` and decodes each segment before it matches, so `POST /%76%31/chat/completions` is the completion route while the raw string carries the escapes: the hook matched nothing and the request reached the handler with no credential (`404 endpoint_not_available` where every plain spelling answered `401`). `src/http/request-path.js` now decodes segment by segment, after the query is stripped so an escaped `?` cannot fabricate one, and leaves an undecodable segment as it arrived rather than throwing on a public route. - `GET /metrics` reported every provider as enabled: the gauge was derived from a field `liveStats()` never set, so `enabled - available` - the "how many are unhealthy" expression - read 1 for a fleet with nothing enabled. - `/api/overview` built its health row from `snapshot.available`, which ignores `enabled`, and drew a green dot on a disabled provider beside a KPI in the same payload that read 0 available. - The CSV export hijacks the reply and returned without handing the connection back, so `socket.gatewayBusy` stayed set and every later parser error on that keep-alive socket got a bare close instead of the documented envelope. - `SESSION_FREE_PATHS` was compared against the target as it arrived, while the router runs with `ignoreTrailingSlash`: `POST /api/auth/login/` could never succeed and `POST /api/auth/logout/` answered 401 without clearing the stale cookie it exists to clear. - A streaming client that stopped reading was warned about and then abandoned: `noteGone()` stops writing and nothing closed the response, so the socket stayed open with the unwritten bytes buffered and the client hung until its own timeout. The deadline now destroys it. - `hasUsageOption` was re-derived from the raw body with `=== true`, so the spellings `parseBool` accepts (`"true"`, `1`) were recorded as "not asked". - An unknown command-line option was silently ignored and the router booted; it is now refused with exit 2 and the usage line. - `authRequirement()` was dead code whose comment claimed a test asserted it; the URL validator carried an unreachable branch; three comments stated the opposite of their code (the queue's release contract, `cooldownMs` on a classification, and a method that does not exist by that name). - The README listed `not_found` as an error `code` the router never sends, and CONTRIBUTING.md claimed merge commits are judged on GitHub's generated title when the checker excludes them on purpose. - `METRICS_ENABLED` was a runtime key that appeared in no Settings group, so the dashboard discarded the row and the endpoint could not be switched from the UI. The Logs drawer's body disclosure carried its state only as a rotated chevron, with no `aria-expanded`, and printed `yes`/`no` where the copy table has `Yes`/`No`; the Models badge kept its own copy of `default`. Verified: `pnpm run check`, `pnpm run typecheck`, `pnpm run test:web` (17), `pnpm test:unit` (483 checks), `SMOKE_SLOW=1 pnpm test:smoke` (394 checks), `pnpm run build`. The Docker image was not built - no Docker here.
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.
A seventh audit of the gateway, the engine, the dashboard and the docs. Each fix has a test that fails without it.
Security / auth
request.urlagainst/v1/, but the router decodes each segment before matching:POST /%76%31/chat/completionsreached the handler with no credential (404where every plain spelling answered401).src/http/request-path.jsnow decodes segment by segment, after the query is stripped.SESSION_FREE_PATHSwas compared against the target as it arrived while the router runs withignoreTrailingSlash, soPOST /api/auth/login/could never succeed andPOST /api/auth/logout/answered 401 without clearing the stale cookie.Wrong numbers
GET /metricsreported every provider as enabled (the gauge read a fieldliveStats()never sets)./api/overviewdrew a green dot on a disabled provider while the KPI in the same payload read 0 available.hasUsageOptionwas re-derived from the raw body, so"true"and1were recorded as "not asked".Resource handling
socket.gatewayBusystayed set and later parser errors on that socket got a bare close (invariant 14).Dead code and lying comments
authRequirement()(never called, with a comment claiming a test asserted it), an unreachable URL-validation branch, and three comments that stated the opposite of their code.Docs and dashboard
not_foundas an errorcode; CONTRIBUTING.md no longer claims merge commits are judged on GitHub's generated title.METRICS_ENABLEDwas a runtime key in no Settings group (the page discarded it); the Logs body disclosure carriesaria-expanded; two hard-coded strings moved into the copy table.Verified:
pnpm run check,typecheck,test:web(17),test:unit(483 checks),SMOKE_SLOW=1 pnpm test:smoke(394 checks),pnpm run build. Docker image not built - no Docker here.