TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Praashh/buildml/llms.txt
Use this file to discover all available pages before exploring further.
submissionRouter handles code execution and grading for Buildml problems. All three procedures require an authenticated session. Execution is asynchronous — both run and submit dispatch a job to QStash and return immediately. You then poll getStatus until the job finishes. Rate limits are enforced per user via Upstash Redis to prevent abuse.
submission.run
Executes user code against the problem’s test suite without persisting a result to the database. Ideal for the “Run” button in the editor where quick feedback is needed but the attempt shouldn’t count toward the user’s submission history.
Type: mutation — Auth: protected (session required)
Input: { problemId: string, code: string }
The CUID of the
Problem to run the code against.The user’s Python solution code to execute.
TOO_MANY_REQUESTS error.
Flow
Validate rate limit
Checks the
runRateLimit bucket (5 requests / 10 s) keyed by userId in Redis. Throws TOO_MANY_REQUESTS if the bucket is exhausted.Generate a run ID
Creates a random UUID (
crypto.randomUUID()) to uniquely identify this execution attempt.Publish to QStash
Dispatches a
RUN job to the /api/webhooks/process-submission endpoint via QStash, carrying type, runId, problemId, code, and userId.Usage
Response
A UUID string identifying this run attempt. Use it as the input to
getStatus.Errors
submission.submit
Executes user code and persists the result as a Submission record in PostgreSQL. Use this for the “Submit” button — the result appears in the user’s history and counts toward leaderboard scores.
Type: mutation — Auth: protected (session required)
Input: { problemId: string, code: string }
The CUID of the
Problem to submit the code against.The user’s Python solution code to submit.
TOO_MANY_REQUESTS error.
Flow
Validate rate limit
Checks the
submitRateLimit bucket (2 requests / 30 s) keyed by userId. Throws TOO_MANY_REQUESTS if exhausted.Create Submission record
Inserts a new
Submission row into PostgreSQL with status: "PENDING", linking it to problemId and the authenticated userId.Publish to QStash
Dispatches a
SUBMIT job to /api/webhooks/process-submission via QStash, carrying type, submissionId, and userId.Usage
Response
The newly createdSubmission database record:
Unique CUID identifier for the submission.
CUID of the associated
Problem.CUID of the authenticated user who submitted the code.
The Python code that was submitted.
Always
"PENDING" at creation time. The webhook worker updates this to PASS, FAIL, or ERROR after execution completes.Execution output.
null initially; populated by the webhook worker after the executor responds.ISO 8601 timestamp of submission creation.
Errors
submission.getStatus
Polls for the result of a run or submit operation. Exactly one of submissionId or runId must be provided. This is the single procedure for checking execution progress regardless of whether the attempt was a run (ephemeral, stored in Redis) or a full submission (persistent, stored in PostgreSQL).
Type: query — Auth: protected (session required)
Input: { submissionId?: string, runId?: string }
The CUID of a
Submission record returned by submission.submit. When provided, the status is read from PostgreSQL.The UUID returned by
submission.run. When provided, the status is read from the Redis key run_result:{runId}. Returns { status: "PENDING", output: null } if the executor has not yet written a result.At least one of
submissionId or runId must be supplied. If neither is provided, the procedure throws a BAD_REQUEST error.Polling Pattern
UserefetchInterval to automatically re-query until the status leaves PENDING:
Response
Current execution status. One of:
| Value | Meaning |
|---|---|
PENDING | The job has been dispatched but the executor has not yet responded. |
PASS | All test cases passed. |
FAIL | One or more test cases failed. |
ERROR | The code raised an unhandled exception or the executor encountered an error. |
Human-readable output string produced by the executor. Format:
"N/M tests passed" followed by per-test results (✓ / ✗) and optional stderr. null while still PENDING.