Stop a client wildcard from covering literal endpoint routes - #210
Merged
Conversation
EndpointClientCoverageTests enforces "every API endpoint needs both
clients", but its matcher accepted a wildcard on either side. A client
call like api/admin/settings/{section} normalizes to
api/admin/settings/* and then silently covered every literal sibling
route under that path — which is how the effective-sizing endpoint
shipped without a CLI client while the guard reported the surface as
covered (#89).
Two fixes:
- IsCovered now requires segment equality, so a client wildcard only
satisfies an endpoint parameter.
- NormalizeRoute keeps a segment's literal prefix. The query-string
idiom $"api/alerting/deliveries{qs}" collapsed to api/alerting/*,
which both lost the route it actually calls and handed the matcher a
wildcard covering catalog/preview-filter/preview-rule.
The matcher itself had no test — the reason this regressed invisibly —
so it gets one covering both rules.
That surfaces six real gaps. Two are closed:
- np alerting catalog + the get_alerting_catalog MCP tool. Rules are
authored as JSON, so the vocabulary (event types, filter fields,
channels) has to be readable outside the web UI.
- WorkflowResolver resolves names through GET /api/workflows/by-name,
which it previously claimed did not exist. np now matches the engine,
the API and the trigger path (exact case wins, then case-insensitive,
ambiguity is an error) instead of dragging the whole workflow list
over the wire to filter it client-side.
The remaining four are documented gaps: the two stateless rule-builder
previews, plus workflows/export and move-folder on the MCP side, which
follow the existing bulk-export and folder-RBAC gaps.
Closes #179
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.
EndpointClientCoverageTestsexists to enforce "Jeder neue API-Endpoint braucht beide Clients" at the level of endpoint existence — and it reported the surface as covered while theeffective-sizingendpoint shipped without a CLI client (#89).Cause
Two independent leniencies, both in the test:
IsCoveredaccepted a wildcard on either side. The CLI'sapi/admin/settings/{section}normalizes toapi/admin/settings/*, which then matched every literal sibling route under that path. This applies wherever a client has a by-id/by-name/by-section call next to literal siblings — i.e. everywhere it mattered.NormalizeRoutecollapsed any segment containing{to*. The query-string idiom$"api/alerting/deliveries{qs}"therefore becameapi/alerting/*: the deliveries call site both lost the route it actually calls and gained a wildcard coveringcatalog,preview-filterandpreview-rule.The matcher had no test of its own, which is why this regressed invisibly. It has one now (7 cases pinning both rules).
Surfaced gaps
Tightening surfaces 4 CLI + 5 MCP routes on current
main. Two are closed here:np alerting catalog+ MCPget_alerting_catalog— rules are authored as JSON, so the vocabulary (event types, filter-referenceable fields, deliverable channels) has to be readable outside the web UI. Mirrors the existingnp system-alert catalog.GET /api/workflows/by-name/{name}—WorkflowResolverused to list all workflows and filter client-side, with a comment claiming the route did not exist.npnow resolves names exactly like the engine, API and trigger path do (exact case wins, then case-insensitive, ambiguity is an error).Four stay as documented known gaps:
preview-filter/preview-rule(stateless dry-runs for the rule builder's live preview, same category as the already-documentedsystem/preview), and MCP-sideworkflows/export/workflows/{id}/move-folder(bulk export and folder RBAC already have documented MCP gaps).Tests
EndpointClientCoverageTests— newMatcher_TreatsWildcardsAsParametersOnlytheory + both guards for both clients.WorkflowResolverTests— rewritten around the by-name endpoint, including 404/409 translation and "the list endpoint is not called".CommandIntegrationAlertingTests.AlertingCatalog_RendersFieldsAndChannels,AlertingToolsTests.GetAlertingCatalog_ReturnsTheRuleVocabulary.Run:
dotnet test tests/NodePilot.Cli.Tests --filter "EndpointClientCoverage|ApiDtoParity|WorkflowResolver|CommandIntegrationAlerting"→ 33 passed;tests/NodePilot.Mcp.Tests --filter "AlertingToolsTests|DocumentationCountsTests"→ 27 passed.Doc surfaces updated for the new tool (
DocumentationCountsTestsenforces the count): CLAUDE.md, README,docs/mcp-server.md,docs/alerting.md, docs-sitecli.md+mcp-server.md.Closes #179