feat: add mock upstream support across HTTP e2e suites#73
Merged
Conversation
There was a problem hiding this comment.
2 issues found across 18 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="drift/instrumentation/django/e2e-tests/src/views.py">
<violation number="1" location="drift/instrumentation/django/e2e-tests/src/views.py:102">
P2: The fallback response in create_post can raise UnboundLocalError when json.loads fails, because data is only defined inside the try. Initialize data before the try or guard access in the except block so the fallback path works on invalid JSON.</violation>
</file>
<file name="drift/instrumentation/aiohttp/e2e-tests/src/app.py">
<violation number="1" location="drift/instrumentation/aiohttp/e2e-tests/src/app.py:28">
P2: This patch overrides session-level timeouts. For example, `/test/timeout` creates `ClientSession(timeout=timeout)` but the patched `_request` replaces it with `EXTERNAL_HTTP_TIMEOUT_SECONDS`, so explicit session timeouts are ignored. Preserve session-level timeouts when callers set them, and only apply the external default when the session is using aiohttp’s default timeout.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
sohankshirsagar
approved these changes
Feb 26, 2026
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.
Summary
Add deterministic mock-upstream support across all HTTP-focused e2e instrumentation suites, and centralize external HTTP configuration so benchmarks/tests are stable and easy to run offline while still allowing real-upstream overrides.
Changes
drift/instrumentation/e2e_common/external_http.pyto centralizeUSE_MOCK_EXTERNALSandMOCK_SERVER_BASE_URLhandling, shared external timeout defaults, and URL rewrite helpers for mock routingdrift/instrumentation/e2e_common/mock_upstream/mock_server.pyto cover broader endpoint behavior used by e2e apps (jsonplaceholder/httpbin-style routes, status/redirect/text/binary/auth flows, and legacy-compatible paths).mock-upstreamservice into docker compose for all relevant suites and default to mock mode with override support:django,fastapi,flask,requests,httpx,urllib,urllib3,aiohttp.django/fastapi/flask) to use shared external HTTP helpers instead of per-app duplicated mock config.USE_MOCK_EXTERNALS=0.