fix(rate-limit): make unstable resource fields optional and allow passthrough#3
Open
qyo123oyq wants to merge 1 commit into
Open
fix(rate-limit): make unstable resource fields optional and allow passthrough#3qyo123oyq wants to merge 1 commit into
qyo123oyq wants to merge 1 commit into
Conversation
…sthrough GitHub's /rate_limit response no longer includes `code_scanning_upload`, and the set of resource fields varies by account type/period. The current schema marks all resource fields as required, so `RateLimitSchema.parse()` throws on real responses (e.g. MCP error -32603: ...code_scanning_upload Required). - Keep core/search/graphql required (always present). - Mark integration_manifest, code_scanning_upload, actions_runner_registration, scim, dependency_snapshots as optional. - Add .passthrough() so newly introduced resource fields don't break parsing.
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.
Problem
get_rate_limitfails with:Root cause
RateLimitSchemainsrc/operations/rate_limit.tsmarks every resource field as required (z.objectdefaults to required). GitHub's/rate_limitresponse no longer includescode_scanning_upload, and the set of resource fields varies by account type and over time, soRateLimitSchema.parse(response)throws on real responses.Changes
In
src/operations/rate_limit.ts:core,search,graphqlrequired (always present in practice).integration_manifest,code_scanning_upload,actions_runner_registration,scim,dependency_snapshotsas.optional()..passthrough()on theresourcesobject so newly introduced resource fields don't break parsing.Verification
Against the live GitHub API,
get_rate_limitnow returns the full payload instead of throwing. The real response contains 14 resource entries —code_scanning_uploadis absent (confirming the root cause), and 7 fields not present in the schema (source_import,code_scanning_autofix,dependency_sbom,audit_log,audit_log_streaming,code_search,copilot_usage_records) are now tolerated by.passthrough().Sample (excerpt):
{ "resources": { "core": { "limit": 5000, "used": 2, "remaining": 4998, "reset": 1782318768 }, "search": { "limit": 30, "used": 0, "remaining": 30, "reset": 1782315333 }, "graphql": { "limit": 5000, "used": 0, "remaining": 5000, "reset": 1782318873 }, "integration_manifest": { "limit": 5000, "used": 0, "remaining": 5000, "reset": 1782318873 }, "actions_runner_registration": { "limit": 10000, "used": 0, "remaining": 10000, "reset": 1782318873 }, "scim": { "limit": 15000, "used": 0, "remaining": 15000, "reset": 1782318873 }, "dependency_snapshots": { "limit": 100, "used": 0, "remaining": 100, "reset": 1782315333 }, "source_import": { "limit": 100, "used": 0, "remaining": 100, "reset": 1782315333 }, "audit_log": { "limit": 1750, "used": 0, "remaining": 1750, "reset": 1782318873 }, "code_search": { "limit": 10, "used": 0, "remaining": 10, "reset": 1782315333 } }, "rate": { "limit": 5000, "used": 2, "remaining": 4998, "reset": 1782318768 } }Build passes (
yarn build→tsc && shx chmod +x dist/*.js) with no errors.🤖 AI usage disclosure: The bug analysis, patch, build verification, and the live
get_rate_limitAPI test for this PR were produced with assistance from an AI coding agent (ZCode). The change was validated end-to-end against the live GitHub API. Submitted at the human contributor's request and under their review; human author confirms the patch and description are accurate.