Skip to content

Fix CheckResponseSchema rejecting numeric memory/runtime fields from LeetCode API - #57

Merged
SPerekrestova merged 2 commits into
mainfrom
copilot/fix-check-response-schema
Sep 15, 2026
Merged

SPerekrestova merged 2 commits into
mainfrom
copilot/fix-check-response-schema

Conversation

Copilot AI commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

LeetCode's /submissions/detail/<id>/check/ endpoint doesn't consistently return runtime/memory as formatted strings (e.g. "58.1 MB") — it sometimes returns raw numbers. CheckResponseSchema only accepted strings, so .parse() threw a ZodError and submit_solution surfaced a schema error even when the underlying submission was accepted.

Schema

  • Widened runtime/memory in CheckResponseSchema to z.union([z.string(), z.number()])
  • Updated LeetCodeCheckResponse type to string | number accordingly

Service layer

  • In leetcode-global-service.ts, coerce runtime/memory to strings via String(...) when building SubmissionResult, preserving its existing string contract for consumers regardless of what shape LeetCode returns
runtime: result.runtime !== undefined ? String(result.runtime) : undefined,
memory: result.memory !== undefined ? String(result.memory) : undefined,

Tests

  • Added a regression test in service-layer.test.ts covering a SUCCESS check response with numeric runtime/memory, asserting the submission is accepted and values are coerced to strings

@coderabbitai

coderabbitai Bot commented Sep 15, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 886fffc1-4e74-4c88-b65f-2d5fc22b51df

📥 Commits

Reviewing files that changed from the base of the PR and between 0084a49 and 348a591.

📒 Files selected for processing (4)
  • src/leetcode/leetcode-global-service.ts
  • src/leetcode/schemas.ts
  • src/types/submission.ts
  • tests/services/service-layer.test.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The 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.

Changes

Submission metric handling

Layer / File(s) Summary
Metric response contract
src/leetcode/schemas.ts, src/types/submission.ts
runtime and memory accept string or number values while remaining optional.
Accepted result normalization
src/leetcode/leetcode-global-service.ts, tests/services/service-layer.test.ts
Defined numeric metrics are converted to strings in accepted results. The test verifies "72" and "42.5" with the accepted status.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 348a5

The change accepts numeric submission metrics and normalizes them to strings without an identified merge-blocking risk.

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch copilot/fix-check-response-schema

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI changed the title [WIP] Fix CheckResponseSchema to accept numeric memory/runtime fields Fix CheckResponseSchema rejecting numeric memory/runtime fields from LeetCode API Sep 15, 2026
Copilot AI requested a review from SPerekrestova September 15, 2026 18:37
@SPerekrestova
SPerekrestova marked this pull request as ready for review September 15, 2026 18:41
Copilot AI lite review requested due to automatic review settings September 15, 2026 18:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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.

@SPerekrestova
SPerekrestova merged commit 6196c2b into main Sep 15, 2026
4 checks passed
@SPerekrestova
SPerekrestova deleted the copilot/fix-check-response-schema branch September 15, 2026 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CheckResponseSchema rejects numeric memory/runtime fields from LeetCode API

3 participants