Repository navigation
ci: check api routes against openapi spec and harden workflows - #5675
Open
martinconic wants to merge 1 commit into
Open
martinconic wants to merge 1 commit into
martinconic wants to merge 1 commit into
Conversation
Add a test that walks the API router and compares every route and its
HTTP methods with openapi/Swarm.yaml, in both directions. Methods are
read from the Allow header of the method not allowed response, so the
check needs no changes to the router. Metrics, profiling and the index
pages are intentionally left out of the spec.
The check found one gap: HEAD on /bzz/{address}/{path} was served but
not documented. Document it.
Pass the branch name and PR author to the beekeeper debug steps through
environment variables instead of inline expressions, and install
commitlint in the PR title workflow without running install scripts.
martinconic
requested review from
acud,
akrem-chabchoub,
aloknerurkar,
gacevicljubisa and
sbackend123
October 23, 2026 12:34
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.
Checklist
Description
Follow-up to #5673. The checks added there only look at what the spec already documents, so a new route added to the router without a spec entry would go unnoticed. This PR closes that gap, and also cleans up two existing security warnings in our workflows.
Route check (
pkg/api/router_spec_test.go)A unit test walks the real API router and compares it with
openapi/Swarm.yamlin both directions:Most routes keep their methods inside
jsonhttp.MethodHandler, which mux can't see. The test sends each route a request with an unknown method and reads theAllowheader of the 405 response, so the router needs no changes. The only additions outside the test are aRouter()accessor and aRootPathconstant inexport_test.go.Some routes are intentionally not in the spec and are skipped:
/,/robots.txt,/metricsand/debug/*(pprof, expvar). The/v1prefixed copies and the*.swarm.localhostsubdomain routes are skipped too, since they serve the same handlers.It runs with the normal unit tests, takes milliseconds, and fails with messages like:
Spec fix found by the check
HEAD /bzz/{address}/{path}is served but was not documented. The spec only hadHEAD /bzz/{address}, which is really a redirect to/bzz/{address}/. I added the HEAD operation to/bzz/{address}/{path}, using the same headers and responses as the existing one.Workflow hardening
beekeeper.yml: the two debug steps used${{ github.head_ref }}directly inside the shell script. Branch names come from the PR author, so this is a script injection risk (flagged by actionlint). They now go through environment variables, together with the PR author.pr-title.yml: commitlint is now installed with--ignore-scriptsand run fromnode_modules/.bininstead ofnpx(flagged by SonarCloud). I checked that it still accepts valid titles and rejects invalid ones.actionlint now reports no issues for any workflow in the repo.
Open API Spec Version Changes (if applicable)
No version bump here. Documenting an existing endpoint is a patch-level change, and #5674 already bumps the version to 8.2.2. Merging both in the same release covers it.
Motivation and Context (Optional)
Part of #4974: keeping the hand-written spec complete and accurate, so bee-js and other clients can be generated from it.
Related Issue (Optional)
#4974, follow-up to #5673
AI Disclosure