Repository navigation
feat(gateway): add GET /api/v1/submissions/{id} polling endpoint - #57
Closed
Guilherme-M-Mateus wants to merge 5 commits into
Closed
Guilherme-M-Mateus wants to merge 5 commits into
Guilherme-M-Mateus wants to merge 5 commits into
Conversation
Lets clients that missed or outlived the SSE stream fetch a submission's status, verdict and per-test results. - db.GetTestResults: read stored per-test results ordered by test_index - Ownership rules match /api/v1/stream: authenticated callers must own the submission; unauthenticated callers may only read run-mode jobs and must present the stream_token (prevents UUIDv7 enumeration) - Submit mode omits stdout/stderr previews for non-sample tests, same rule as the worker's VERDICT event - Unknown id -> 404; DB errors -> 500 (not masked as 404) - Tests for handler, preview filtering, and GetTestResults; OpenAPI spec Closes stjosephsplacements#46 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #46
Summary
Adds a REST polling endpoint so clients that missed or outlived the SSE stream can fetch a submission's status, verdict and per-test results.
db.GetTestResults(ctx, pool, submissionID): readssubmission_test_resultsordered bytest_indexHandleGetSubmissionregistered atGET /api/v1/submissions/{id}(new fileinternal/gateway/submission.go)stdout_preview/stderr_previewfor non-sample tests, same rule as the worker's VERDICT eventSubmissionResponseschemaAuth: one deviation from the issue
Ownership rules mirror
/api/v1/stream:stream_tokenfromPOST /api/v1/executeis requiredThe issue only says unauthenticated callers may access run-mode submissions. Without the token check this endpoint would bypass the UUIDv7-enumeration protection the SSE handler already has. Trade-off: the token TTL is 30 min, so unauthenticated polling stops working after that. Happy to change this if you'd prefer otherwise.
Tests
internal/gateway: invalid id → 400, DB down → 500, preview filtering (submit vs run, JSON key absent)internal/db:GetTestResultsround-trip inTestInsertResultsAndVerdict(testcontainers, Postgres 18)Local gate (after merging latest
development):go build,go vet,gofmt -s, andgo test -race -count=1 ./...all pass.golangci-lintv2.15.0 reports 0 issues on the lines this PR changes (--new-from-rev origin/development).Heads-up, unrelated to this PR: on current
development,.golangci.ymldoesn't load under v2.15.0 (can't load config: goimports is a formatter). In v2,goimportsandgofmtbelong underformatters:rather thanlinters.enable, so the lint job will probably fail on every branch until that's moved. With that fixed locally, lint shows 4 pre-existing findings (3× errcheck ininternal/queue/pubsub_test.go, 1× whitespace inInsertResultsAndVerdict). I've left them out of this PR to keep it to one concern.Design invariants
None touched. This is a read-only endpoint: no inserts, enqueues, SSE subscription/replay changes, or verdict writes. Insert-before-enqueue, subscribe-before-replay, cancel-safe writes and CAS verdict writes are unaffected.
🤖 Generated with Claude Code