fix(entrypoints): http_methods carries HTTP methods only (#213) - #219
Merged
Merged
Conversation
`_methods_of`'s `match_suffix` branch returned the matched suffix verbatim, and
the shipped `heuristic.http-verb` rule matches `.websocket` alongside the real
verbs -- so `@app.websocket("/ws")` produced `http_methods: ["WEBSOCKET"]`.
`http_methods` is what a consumer filters on to separate routes from other
entrypoints, so a value that is not a method is worse there than an empty list: a
query for POST endpoints is unaffected, but one enumerating distinct methods
reports a method that does not exist.
The branch now emits a verb only when it is one, matching what the class-dispatch
path at the bottom of the module already did. The entrypoint itself is still
recorded -- only the method list changes, and `rule` remains how the shape is
identified.
codeanalyzer-typescript already filters both its `match_suffix` and `export_name`
paths (its #206, the Astro `ALL` export); this closes the same gap 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.
Closes #213.
The bug
_methods_of'smatch_suffixbranch returned the matched suffix verbatim, and the shippedheuristic.http-verbrule matches.websocketalongside the real verbs:So
@app.websocket("/ws")producedhttp_methods: ["WEBSOCKET"]. Reproduced before the fix:http_methodsis what a consumer filters on to separate routes from other entrypoints, so a value that is not a method is worse there than an empty list — a query for POST endpoints is unaffected, but one enumerating distinct methods reports a method that does not exist.The fix
One filter, matching what the class-dispatch path at the bottom of the same module already did: emit
[verb.upper()]only whenverb.lower() in _HTTP_VERBS, else[]. The entrypoint is still recorded — only the method list changes, andrule(heuristic.http-verb) remains how the shape is identified.fastapi.websocket, a separate rule with nomethods:spec, already yielded[]and is untouched.Tests
Three, in
test_entrypoint_decorators.py: the websocket reproducer (entrypoint recorded,routeintact,http_methods == []),@app.getstill yielding["GET"], and an invariant test that walks every shippedmatch_suffixrule, probes each literal suffix its pattern accepts, and asserts the union of everything emitted is a subset of_HTTP_VERBS— so a future rule with a non-verb suffix fails here rather than shipping junk.Gates, run on b120aed
522 passed, 11 skipped(519 before, +3 new)2.0.0at L1–L4, each validates againstAnalysis-a 4runs byte-identical (126592 B)Caveats
WEBSOCKETout ofhttp_methodstoday. No schema shape change:http_methodsstaysList[str],schema_versionstays2.0.0.match_suffixandexport_namepaths (matching.ts:92,103, its fix(neo4j): the graph projection carries the facts analysis.json carries #206); codeanalyzer-java has nohttp_methodssurface at all yet; python-sdk carrieshttp_methodsonly on its TypeScript model, and this changes a value rather than a shape.