Fix CheckResponseSchema rejecting numeric memory/runtime fields from LeetCode API - #57
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe submission response contract now accepts numeric runtime and memory values. Accepted submissions convert defined metrics to strings. A service test covers numeric polling results and preserves the accepted status. ChangesSubmission metric handling
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The change accepts numeric submission metrics and normalizes them to strings without an identified merge-blocking risk. ✨ Finishing Touches✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🟢 Approval recommended
All reviewed changes are covered and no blocking issues were identified.
Pull request overview
Updates submission handling to accept numeric LeetCode runtime and memory values while preserving string outputs.
Changes:
- Widened schemas and types to accept strings or numbers.
- Normalized accepted values to strings.
- Added regression coverage.
File summaries
| File | Description |
|---|---|
tests/services/service-layer.test.ts |
Tests numeric response handling. |
src/types/submission.ts |
Updates response field types. |
src/leetcode/schemas.ts |
Accepts numeric runtime and memory fields. |
src/leetcode/leetcode-global-service.ts |
Normalizes values to strings. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
LeetCode's
/submissions/detail/<id>/check/endpoint doesn't consistently returnruntime/memoryas formatted strings (e.g."58.1 MB") — it sometimes returns raw numbers.CheckResponseSchemaonly accepted strings, so.parse()threw aZodErrorandsubmit_solutionsurfaced a schema error even when the underlying submission was accepted.Schema
runtime/memoryinCheckResponseSchematoz.union([z.string(), z.number()])LeetCodeCheckResponsetype tostring | numberaccordinglyService layer
leetcode-global-service.ts, coerceruntime/memoryto strings viaString(...)when buildingSubmissionResult, preserving its existingstringcontract for consumers regardless of what shape LeetCode returnsTests
service-layer.test.tscovering aSUCCESScheck response with numericruntime/memory, asserting the submission is accepted and values are coerced to strings