From 5438199b2dc2ffd65e62b707bd19d5d8d4c26b92 Mon Sep 17 00:00:00 2001 From: shilimesfriend <1700635609@qq.com> Date: Wed, 24 Jun 2026 23:40:27 +0800 Subject: [PATCH] fix(rate-limit): make unstable resource fields optional and allow passthrough 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. --- src/operations/rate_limit.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/operations/rate_limit.ts b/src/operations/rate_limit.ts index a2f7a2b..932360e 100644 --- a/src/operations/rate_limit.ts +++ b/src/operations/rate_limit.ts @@ -10,16 +10,18 @@ export const RateLimitResourceSchema = z.object({ }); export const RateLimitSchema = z.object({ - resources: z.object({ - core: RateLimitResourceSchema, - search: RateLimitResourceSchema, - graphql: RateLimitResourceSchema, - integration_manifest: RateLimitResourceSchema, - code_scanning_upload: RateLimitResourceSchema, - actions_runner_registration: RateLimitResourceSchema, - scim: RateLimitResourceSchema, - dependency_snapshots: RateLimitResourceSchema, - }), + resources: z + .object({ + core: RateLimitResourceSchema, + search: RateLimitResourceSchema, + graphql: RateLimitResourceSchema, + integration_manifest: RateLimitResourceSchema.optional(), + code_scanning_upload: RateLimitResourceSchema.optional(), + actions_runner_registration: RateLimitResourceSchema.optional(), + scim: RateLimitResourceSchema.optional(), + dependency_snapshots: RateLimitResourceSchema.optional(), + }) + .passthrough(), rate: RateLimitResourceSchema, });