Repository navigation
Conversation
Since Go 1.22 a net/http ServeMux pattern may name a method and a host
before the path: mux.HandleFunc("POST /v1/payments", h),
"GET /v1/payments/{id}", "api.example.com/v1/x". Every route
registration gate wanted the first argument to open with a slash (the
extractor's handler capture, find_route_path_in_args in the parallel
pass, and the three gates in the sequential pass), so such a
registration minted no Route and no HANDLES edge, while the same file
written with "/v1/payments" had both.
cbm_service_pattern_mux_split reads the "[METHOD ][HOST]/[PATH]"
grammar. For Go files only, the path of such a pattern now registers
the route, the Route takes the pattern's method when the callee names
none (Handle/HandleFunc are ANY), and a host is dropped from the path.
Both passes share cbm_pipeline_mux_route_path and
cbm_pipeline_route_reg_method so their Routes stay identical. Other
languages and plain "/path" patterns take the unchanged path.
Fixes DeusData#2537
Signed-off-by: Gaurav Dubey <gauravdubey0107@gmail.com>
|
Thanks for opening this — it has been seen, and it is queued. This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence. Current review status: working through a backlog. What that means for this PR, concretely:
Things that will genuinely speed it up whenever review does happen:
If this fixes a bug, a reproduction we can run is worth more than a description of the symptom. Thanks for contributing, and sorry in advance for the wait. |
|
This comment was written by an AI agent operating this account on behalf of @gaurav0107. The red To check: |
The Go 1.22 pattern split ran for every route-verb callee, so other Go
calls whose name ends in Get/Post/Put/Delete/Patch became route
registrations: st.Get("users/123") on a project method minted
__route__GET__/123 and lost its CALLS edge to Store.Get, and
c.Get("https://api.example.com/v1/x") split "https:" off as a host and
minted __route__GET__//api.example.com/v1/x, in both passes.
cbm_service_pattern_mux_route_path reads the pattern only for a callee
ending ".Handle" or ".HandleFunc", and never for an argument containing
"://". The extractor's handler capture and both passes (route_reg_path,
find_route_path_in_args, cbm_pipeline_route_reg_method) go through it,
so the two passes still mint identical Routes. Two negative cases
extend pipeline_go_servemux_method_patterns_issue2537 in both passes,
and the infrascan unit covers the gate.
Refs DeusData#2537
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
|
Thank you so much, Gaurav, for this careful fix. Your parser follows Go's "[METHOD ][HOST]/[PATH]" rule exactly, the shared helpers keep the sequential and parallel passes byte-identical, and the legacy "/path" and Python "GET /py" controls in the test made the change easy to trust. We pushed two small commits on top of your branch so it can land:
Please pull before pushing again, so your next push builds on these commits. Thanks again for the contribution! |
|
This comment was written by an AI agent operating this account on behalf of @gaurav0107. Thank you for the review and for the two follow-up commits. Restricting pattern parsing to |
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
|
Thanks again, @gaurav0107. Several other pull requests landed on main this evening, including changes in files this one also touches, so we merged current main into your branch once more (one signed-off merge commit, 20a6f1f; your changes are untouched). That keeps the required checks honest against today's tree; we will merge once they are green. Please pull before pushing again. |
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
|
Thank you for your patience, @gaurav0107. CI went green on this branch, but meanwhile #2430 merged changes into tests/test_pipeline.c, which this pull request also touches, so that green no longer covered today's main. We merged current main into the branch once more (one merge commit, 3b646da; your changes are untouched) and will merge as soon as the fresh checks are green. Please pull before pushing again. |
origin/main (DeusData#2305) moved the route-registration checks of the sequential resolver into calls_emit_route_call and made emit_classified_edge return whether it emitted. Keep the structure and bookkeeping of main and carry the ServeMux pattern reading over: emit_classified_edge and calls_emit_route_call now take the registration path from route_reg_path, so "POST /v1/x" patterns register in both passes as before. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
|
Thank you again @gaurav0107 for this fix. Reading the method and host out of Go 1.22 ServeMux patterns, so that "POST /v1/payments" becomes a POST route with its handler, closes a real gap for every modern net/http service, and the tests run the fixture through both the sequential and the parallel pass, which made this update easy to check. We pushed one more commit to your branch: a merge of current main, signed off (f33f976). Main had moved the route-registration checks of the sequential call resolver into a shared helper (calls_emit_route_call) and now records whether each call emitted an edge. That conflicted in three small places in src/pipeline/pass_calls.c. We kept the new structure from main and carried your change over: emit_classified_edge and calls_emit_route_call now take the registration path from your route_reg_path, so ServeMux patterns register exactly as before. pass_parallel.c merged cleanly and is unchanged from your version. Your servemux tests and the extraction, infrascan, pipeline, parallel and incremental suites pass on the merged tree. Please pull before pushing again so your local branch picks up the merge. Thanks for the careful work! |
|
Thank you @DeusData for keeping this branch current with main (merges 20a6f1f, 3b646da and f33f976), and for carrying the route_reg_path change through the calls_emit_route_call refactor in |
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
|
Thank you again, @gaurav0107, for your patience with this one. Two pull requests merged into main a few minutes ago (#2754 and #2090), and they touch src/pipeline/pass_parallel.c, which this pull request also changes. So we merged current main into your branch once more (one merge commit, d758fd6; it merged cleanly and your own change is untouched), checked that the merged files still compile, and started a fresh CI run. We will merge as soon as the required checks are green. Please pull before pushing again so the merge commit is kept. |
|
Thanks for merging main in again (d758fd6) and kicking off CI. I will not push to this branch again without pulling first, so the merge commit stays in place. |
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
|
Thank you for your patience, @gaurav0107. A pull request that merged into main a few minutes ago (#1710) changes internal/cbm/extract_calls.c, which this pull request also changes, so the CI run in progress here could no longer vouch for today's main. We merged current main into your branch once more (one merge commit, fec0b87; it merged cleanly and your own change is untouched) and started a fresh run. We will merge once the required checks are green. Please pull before pushing again. |
|
Thanks for merging main in and restarting CI. Noted on fec0b87; I'll pull before any further push. |
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
|
Thank you for your patience, @gaurav0107. Main has moved since the last CI run on this branch, and some of the new commits change src/pipeline/pass_calls.c and pass_parallel.c, which this pull request also changes, so that run can no longer vouch for today's main. Separately, the Windows leg of that run failed with an intermittent crash at the start of a few test suites that we are tracking on our side; it is not caused by your change. We merged current main into your branch (one merge commit, 46c95bc; it merged cleanly and your own change is untouched) and started a fresh run. We will merge once the required checks are green. Please pull before pushing again. |
|
Thanks for merging main in and restarting CI, and for the note about the Windows crash. I've synced my local branch to 46c95bc and will pull before any further push. |
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
|
Thank you for your patience, @gaurav0107. The macOS legs of the last CI run here were cancelled by GitHub itself: it is retiring its macOS 14 runners on November 2 and ran scheduled brownouts beforehand, so those jobs never got a runner. Nothing in your change caused it. Main now runs CI on macOS 15 (#2849), so we merged current main into your branch (one merge commit, 3e075d5; it merged cleanly and your own change is untouched) to get a run on the new runners. Please pull before pushing again. |
|
Thanks for explaining the macOS runner cancellations and for merging main in. I have pulled 3e075d5 locally and will build on it for any further pushes. |
|
Merged as 747665d - thank you, @gaurav0107! Go 1.22 ServeMux patterns with a method and an optional host now become Routes with their method, and the handler gets its HANDLES edge, while plain paths keep working as before. Thank you also for accepting the follow-up narrowing so cleanly. |
What does this PR do?
Fixes #2537. Since Go 1.22 a
net/httpServeMux pattern may name a method and a host before the path (mux.HandleFunc("POST /v1/payments", h),"GET /v1/payments/{id}","api.example.com/v1/x"). These registrations produced noRouteand noHANDLESedge, because every route-registration gate required the first argument to start with/:internal/cbm/extract_calls.c: the handler argument was captured only for a/-prefixed pathsrc/pipeline/pass_parallel.c:find_route_path_in_args/is_route_path_shapedsrc/pipeline/pass_calls.c: the three sequential-pass gates (emit_classified_edge, the PHP/Laravel: routes inside Route::prefix()->group() produce no Route nodes #952 unresolved-callee fallback, the cross-language refusal fallback)The change:
cbm_service_pattern_mux_split()parses the[METHOD ][HOST]/[PATH]grammar. METHOD is a run of uppercase letters ended by spaces/tabs (Go cuts at the first space or tab). HOST is a non-empty run with no whitespace before the first/. It returns a pointer to the path inside the written pattern./path, goes through the existing code unchanged..Handle/.HandleFuncareANY). A callee that names its verb keeps it.cbm_pipeline_mux_route_path,cbm_pipeline_route_reg_method), so they produce byte-identical Routes.Evidence
Machine: Amazon Linux 2023, x86_64, clang 15.0.7 (gcc here has no
libasan, so the sanitizer build uses clang).New tests (reproduce-first, run against the unfixed tree first):
extraction: extract_go_servemux_method_pattern_handler_issue2537method->second_arg_name is NULLpipeline: pipeline_go_servemux_method_patterns_issue2537(sequential and parallel, with 52 padding files to go pastMIN_FILES_FOR_PARALLEL)post[mode] == 0, expected 1infrascan: infrascan_servemux_pattern_split_issue2537(grammar edge cases: tabs, host:port,DELETE /, lowercase word, no path, oversize method)The pipeline test also covers a host-only pattern, a legacy
/v1/legacycontrol (still__route__ANY__), no__route__ANY__twin for a method pattern, and a Pythonadd_url_rule("GET /py", ...)that must still produce no route.Commands:
End to end with a product build (
scripts/build.sh), using the issue's repro plus a host-only registration:__route__POST__/v1/payments,__route__GET__/v1/payments/{},__route__GET__/v1/hosted/pathcontrol__route__ANY__…Not verified locally
scripts/test.shvenue run: on main it stops at Step 0w (the published language-count contract, fordocs/index.html,docs/llms.txt,pkg/npm/README.md,scripts/package-release.sh,server.json).scripts/test.sh --contracts-onlygives the same five failures on this branch and on pristine main. This diff doesn't touch those files.scripts/lint.sh: cppcheck 2.20 / clang-format-20 aren't installed here. The changed lines pass clang-format 15 (clang-format-diff). I'm relying on thelintCI job for the rest.Checklist
git commit -s):scripts/check-dco.sh upstream/main..HEADOKmake -f Makefile.cbm test): the 19 related suites above pass. The full venue run wasn't done (see above).make -f Makefile.cbm lint-ci): not run locally (see above).🤖 Opened with Superhuman, an open-source contribution agent.