[GithubSize] Support file paths via query parameter - #12107
Open
Kryptonzy wants to merge 1 commit into
Open
Conversation
Contributor
|
Kryptonzy
marked this pull request as ready for review
August 10, 2026 12:44
Kryptonzy
force-pushed
the
agent/fix-github-file-size-path
branch
from
August 10, 2026 15:23
3d77fe6 to
03765a2
Compare
Member
|
Thanks for the contribution @Kryptonzy ! Perhaps we could stop explicitly supporting the old route, and add a redirector to the new one with the query path parameter, for backwards compatibility. @DCjanus what do you think? |
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.
Summary
Add a query-parameter form of the GitHub file-size badge so filenames that look like badge output formats can be requested without ambiguity:
/github/size/badges/shields.json?path=package.jsonThe existing path-based form remains supported for backward compatibility.
Fixes #10548.
Root cause and approach
In
/github/size/badges/shields/package.json, Shields interprets the final.jsonas the requested badge format. The service consequently receivespackageas the file path and asks GitHub for the wrong file.The service route now permits the path segment to be omitted and accepts
pathin its validated query schema.handle()prefers the existing route path when present, otherwise uses the query path, and returns a clearpath is requirederror if neither is supplied. A second OpenAPI route documents the query form. This adds an unambiguous entry point without breaking existing badge URLs.Verification
npm run test:services -- --only=GithubSize --fgrep='filename matching a badge format'— 1 passing.npm run test:services -- --only=GithubSize --fgrep='File size without a path'— 1 passing./contents/package.json, and verifies a1 KiBbadge.npx --no-install eslint services/github/github-size.service.js services/github/github-size.tester.js— passed.npx --no-install prettier --check services/github/github-size.service.js services/github/github-size.tester.js— passed.npm run defs— passed.Scope
Only
GithubSizerouting/query validation, its OpenAPI definition, and two focused service tests change. Existing route-path and branch behavior are retained.AI assistance
OpenAI Codex (GPT-5) was used to inspect the route/format interaction, implement the minimal backward-compatible change, and run/review the tests and final diff. The repository does not prohibit AI-assisted contributions; this usage is disclosed explicitly.