Repository navigation
🧪 add tests for request_context.py - #19738
undivisible merged 2 commits into
Conversation
Add missing unit tests to cover utility methods and valid/invalid JIT budget headers resolution for FastAPI requests. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 93c1a1c468
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -0,0 +1,157 @@ | |||
| import uuid | |||
There was a problem hiding this comment.
Put the gateway test under the selector's matching path
When a later PR changes only backend/llm_gateway/gateway/request_context.py, the changed-file selector maps backend/llm_gateway/ exclusively to tests/unit/test_llm_gateway_*.py, so this nested test is omitted from the selected PR/pre-push suite and runs only during an --all build. Move it to the matching root-level naming convention or extend AREA_TESTS to include nested gateway tests so the new regression coverage actually guards future changes.
AGENTS.md reference: backend/AGENTS.md:L205-L205
Useful? React with 👍 / 👎.
Git-on-my-level
left a comment
There was a problem hiding this comment.
Test-only addition covering llm_gateway/gateway/request_context.py — reviewed assertion-by-assertion against the source and executed locally.
backend/tests/unit/llm_gateway/gateway/test_request_context.py: all 14 tests pass. The assertions match the production branches exactly: env-gated unavailability whenJIT_BUDGET_CONTRACT_ENVmismatches, contract/run-id grammar (JIT_RUN_ID_PATTERNrejecting both'invalid run id!'and''), non-integer and non-positive budget headers, and the qualification ceilings —max_attempts=4is correctly rejected against the ceiling tuple(3, 2048, 32768, 50000)inrequest_context.py.jit_budget_forward_headersasserts the canonicalX-Omi-Jit-*relay names, andresolve_request_idcovers UUID case-normalization plus opaque-ID regeneration for non-UUID/oversized inputs. The mock ASGI scope inbuild_mock_requestalso exercises therequest.state.request_idfallbacks behindrequest_id_for, including the empty-string and missing-attr paths.- No overlap with existing coverage:
tests/unit/test_llm_gateway_openai_compatible.pytouchesjit_budget_headers_foronly at the router level, so this file fills a real gap. - One non-blocking nit:
from dataclasses import dataclassat the top of the new test file is unused.
Coverage is consistent with the wire contract in backend/docs/runbooks/jit-qa-cloud-run.md. Thanks @undivisible!
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
kodjima33
left a comment
There was a problem hiding this comment.
Test-only PR (request_context.py coverage), not a bug fix - approve-only. CI clean.
kodjima33
left a comment
There was a problem hiding this comment.
Re-confirmed: test/perf/refactor addition, not a bug fix — backend confidence gate requires a bug/issue fix to merge, so this stays approve-only per policy.
kodjima33
left a comment
There was a problem hiding this comment.
undivisible test-only PR (test_request_context.py) — zero production risk
kodjima33
left a comment
There was a problem hiding this comment.
Test-only PR — adds backend/tests/unit/llm_gateway/gateway/test_request_context.py only; zero production risk, CI green.
kodjima33
left a comment
There was a problem hiding this comment.
Test-only coverage addition (undivisible), verified real test content, CI clean/non-blocking, no abuse signal. Approve-only per confidence gate (not a bug fix).
kodjima33
left a comment
There was a problem hiding this comment.
undivisible test-only PR (request_context tests) -- approve, test-only
kodjima33
left a comment
There was a problem hiding this comment.
undivisible test-only addition, zero production risk (per standing memory on the 09-24 flood) — approve only, not a bug fix
kodjima33
left a comment
There was a problem hiding this comment.
Test-only addition for request_context.py - approve-only. CI green.
kodjima33
left a comment
There was a problem hiding this comment.
Test-only coverage addition, not a bug fix — approve only per policy, not merged.
Five unit files fail on current main. Each one passed on its own PR's base and broke when main moved underneath it; none is a product regression. - test_request_context.py (#19738): tested the JIT budget surface that #22209 removed from llm_gateway/gateway/request_context.py. Keep the request-id tests; drop the tests for removed code. - test_users_joan_followup_tombstone_guard.py (#19867): called delete_person_endpoint, but the joan followup route is delete_followup_question_endpoint. - test_developer_from_segments_idempotency.py (#21265): process fakes rejected the trigger=CLIENT_FINALIZE kwarg the router passes since #19788. - test_external_tools_sanitization.py (#19406): the stubbed utils package lacked utils.generated_compute (#21488) and utils.model_text. Stub the default-off gate as disabled and load the stdlib-only model_text for real. - test_batch_upload_storage.py: the database.vector_db stub lacked delete_action_item_vectors_batch, which merge_conversations imports since #15953. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
) * fix(backend): restore pyright-clean main after #22207 and #22326 Main's backend unit shards fail the enforced pyright lane: - database/desktop_previews.py (#22207): 16 reportUnnecessaryIsInstance errors. The runtime guards stay; they move into validators that take `object` (_payload, _string, _expected_generation, _datetime), so the checks are meaningful to pyright. Public signatures, error messages and check order are unchanged. - utils/sync/pipeline.py:process_segment (#22326 on top of #22452): "code is too complex to analyze". Behaviour-neutral split: the two identical cap-hold defer blocks become one hold_for_cap closure, and the final-pass / speaker-identification block moves to _assign_segment_speakers with the same exception handling. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(backend): repair unit tests that drifted from main across merges Five unit files fail on current main. Each one passed on its own PR's base and broke when main moved underneath it; none is a product regression. - test_request_context.py (#19738): tested the JIT budget surface that #22209 removed from llm_gateway/gateway/request_context.py. Keep the request-id tests; drop the tests for removed code. - test_users_joan_followup_tombstone_guard.py (#19867): called delete_person_endpoint, but the joan followup route is delete_followup_question_endpoint. - test_developer_from_segments_idempotency.py (#21265): process fakes rejected the trigger=CLIENT_FINALIZE kwarg the router passes since #19788. - test_external_tools_sanitization.py (#19406): the stubbed utils package lacked utils.generated_compute (#21488) and utils.model_text. Stub the default-off gate as disabled and load the stdlib-only model_text for real. - test_batch_upload_storage.py: the database.vector_db stub lacked delete_action_item_vectors_batch, which merge_conversations imports since #15953. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
🎯 What: The testing gap addressed: created unit tests for llm_gateway/gateway/request_context.py
📊 Coverage: Covered all utility methods such as jit_budget_forward_headers, jit_budget_headers_for, request_id_for, resolve_request_id, and validated_jit_budget_values. Also verified mock Request headers parsing.
✨ Result: Improved overall backend test coverage and caught edge cases related to empty and unparsable states in FastAPI requests.
Failure-Class: none
PR created automatically by Jules for task 12321582620649684028 started by @undivisible