Summary
submit_solution intermittently fails with a schema validation error even when the underlying LeetCode submission was actually accepted:
Check response did not match expected schema: [
{
"code": "invalid_type",
"expected": "string",
"received": "number",
"path": ["memory"],
"message": "Expected string, received number"
}
]
Root cause
In src/leetcode/schemas.ts (compiled to build/leetcode/schemas.js), CheckResponseSchema declares:
runtime: z.string().optional(),
memory: z.string().optional(),
LeetCode's /submissions/detail/<id>/check/ endpoint doesn't consistently return these as formatted strings (e.g. "58.1 MB") — it sometimes returns raw numeric values instead. When that happens, .parse() throws a ZodError, and the tool surfaces this as a failure even though the submission itself succeeded (verifiable via get_recent_submissions, which shows "statusDisplay":"Accepted" for the same submission).
Suggested fix
Widen both fields to accept either type:
runtime: z.union([z.string(), z.number()]).optional(),
memory: z.union([z.string(), z.number()]).optional(),
I applied this locally (patched the cached npx build) and confirmed submissions no longer throw, while get_recent_submissions correctly showed the prior submission as Accepted despite the earlier tool-level error.
Repro
- Call
submit_solution for any problem with a working solution.
- Occasionally (API-dependent), the response's
memory field comes back as a number rather than a string.
- Tool call errors out with the schema mismatch above instead of returning the accepted result.
Summary
submit_solutionintermittently fails with a schema validation error even when the underlying LeetCode submission was actually accepted:Root cause
In
src/leetcode/schemas.ts(compiled tobuild/leetcode/schemas.js),CheckResponseSchemadeclares:LeetCode's
/submissions/detail/<id>/check/endpoint doesn't consistently return these as formatted strings (e.g."58.1 MB") — it sometimes returns raw numeric values instead. When that happens,.parse()throws aZodError, and the tool surfaces this as a failure even though the submission itself succeeded (verifiable viaget_recent_submissions, which shows"statusDisplay":"Accepted"for the same submission).Suggested fix
Widen both fields to accept either type:
I applied this locally (patched the cached npx build) and confirmed submissions no longer throw, while
get_recent_submissionscorrectly showed the prior submission asAccepteddespite the earlier tool-level error.Repro
submit_solutionfor any problem with a working solution.memoryfield comes back as a number rather than a string.