[Feature] : API ENDPOINTS PR 6 : Errors, Logs, and OpenAPI Documentation#1135
Open
pulk17 wants to merge 8 commits into
Open
[Feature] : API ENDPOINTS PR 6 : Errors, Logs, and OpenAPI Documentation#1135pulk17 wants to merge 8 commits into
pulk17 wants to merge 8 commits into
Conversation
e38cc76 to
cfffa04
Compare
7a1ae9a to
439ae42
Compare
|
9 tasks
9 tasks
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.



[FEATURE]
In raising this pull request, I confirm the following (please check boxes):
My familiarity with the project is as follows (check one):
Errors, logs, and OpenAPI documentation (PR 6/6)
Summary
Final part of 6 (supersedes #1117). Adds error/log diagnostics and the OpenAPI
document for the whole API. Also populates
user.github_loginat OAuth login(with a lazy fallback in the run-trigger path), which PR 3's fork-run permission
check depends on.
Endpoints (
mod_api/routes/errors_logs.py)GET /runs/{id}/errors—results:read; derived test errors with?type/?severity/?sample_id.GET /runs/{id}/infrastructure-errors—system:read; infra faultsclassified from progress messages (
?include_stackis admin/contributor only).GET /runs/{id}/error-summary—results:read; counts grouped bytype/severity/sample_id/regression_id.GET /runs/{id}/logs—system:read; cursor-paginated build log (line-offsetcursor capped at 10M;
?level/?source/?contains).GET /runs/{id}/samples/{sid}/logs— placeholder (404); per-sample logs aren'tproduced by the CI worker yet (planned with the CI-VM work).
Log service (
mod_api/services/log_service.py)Streams the log off disk with
itertools.islice(no full-file load) and appliesline-offset cursor pagination + substring filtering.
Auth change (
mod_auth/controllers.py)github_callbacknow storesgithub_login, andfetch_username_from_tokengained a request timeout. This is what lets PR 3's fork-run check identify the
caller's fork owner.
API contract
openapi-ci-api.yaml— OpenAPI 3.0.3 document for all ~26 endpoints(paths, scopes via
x-required-scope, schemas, security); matches theimplemented routes.
scripts/verify_schemathesis.py— property-based contract tests(schemathesis/hypothesis). Kept under
scripts/so standard pytest does notauto-collect it (those deps aren't in
test-requirements.txt); run manually.Testing
189 pytest tests pass; lint/type clean across
mod_api/andtests/api/.Known caveats & design decisions (apply across the API)
Conscious tradeoffs at current scale (~250 samples / ~300 tests per run,
single-process deployment):
with worker count. Redis when we scale out.
isliceoffset, hard-capped at10,000,000 lines to bound DoS. Byte offsets deferred.
Python rather than re-expressing multi-table logic in SQL. Negligible at ~250
runs.
list_run_samples— per-result lazy loads vs one large eagerjoin. Acceptable at ~300 tests/run; eager loading is an easy later win.
blob.exists()— list/summary endpoints inferok/degraded from DB state to avoid a per-row GCS call; download/diff
endpoints (which need the file) do verify.
random secrets, so SHA-256 +
hmac.compare_digest(constant-time) is thecorrect, standard choice; argon2/bcrypt would only add latency. User
passwords separately use passlib/bcrypt in
mod_auth.@require_rolesvs@require_scope— some routes use both deliberately(belt-and-suspenders), not a bug.
document the OpenAPI contract; some handlers build response dicts directly for
simplicity in hot paths.
Conclusion
With this PR the API is structurally complete: runners and bots can orchestrate
the CI pipeline over HTTP/JSON.