Repository navigation
fix(backend): unbreak Backend Unit Tests on main (merge-train collision) - #15219
Merged
Merged
Conversation
#15099 added a required `request: Request` parameter to routers.apps.enable_app_endpoint (for record_product_event telemetry). tests/unit/test_app_enable_install_count.py and tests/unit/test_setup_completed_url_uid_query.py call the endpoint function directly and still used the old 2-arg call, so main's Backend Unit Tests shard has been red with `TypeError: enable_app_endpoint() missing 1 required positional argument: 'request'` since the #15099 merge. record_product_event only reads request.headers and is fail-open, so a minimal ASGI-scope starlette Request with empty headers is a sufficient double -- the same construction tests/unit/test_product_metrics.py already uses for this module. Verification: bash test.sh with BACKEND_UNIT_TEST_FILE_LIST=tests/unit/test_app_enable_install_count.py,tests/unit/test_setup_completed_url_uid_query.py -> 3 passed, 4 passed. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…or-envelope reader #15058 added app/lib/backend/http/api/speech_profile.dart::_errorDetail, a helper called from uploadProfile that does a raw jsonDecode + field access on an error response body to extract a `detail` string. That merged in the same 2026-09-20T14:41Z burst as ~20 other app PRs and made tests/unit/test_app_client_schema_inventory.py's test_inventory_openapi_route_response_decode_migration_complete red on main: the migration-complete gate now sees uploadProfile's called function ranges include _errorDetail's two decode sites and classifies them as an unmodeled 'response_decode' site, tripping the raw_response_decode_site_count assertion. _errorDetail is exactly the shape scripts/inventory_app_client_schemas.py already carves out via NON_REST_RESPONSE_DECODER_FUNCTIONS: it inspects a bounded error envelope to choose an application control path (surface a backend-provided message), it does not decode an OpenAPI response DTO. conversations.dart::isSyncRecoveryWindowExceededResponse is the existing member of that allowlist for the same reason. Add speech_profile.dart::_errorDetail alongside it so the inventory keeps tracking real unmigrated response decoding without false-flagging error- detail extraction. Verification: bash test.sh with BACKEND_UNIT_TEST_FILE_LIST=tests/unit/test_app_client_schema_inventory.py -> 12 passed (previously 1 failed: test_inventory_openapi_route_response_decode_migration_complete). Co-Authored-By: Claude Fable 5.1 <[email protected]>
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
main's "Backend Unit Tests" workflow has been red since 2026-09-20T14:41Z, when ~20 community app/backend PRs merged within about five minutes and semantically conflicted with each other even though every one of them was individually green against its own base. Two independent test failures resulted; this PR fixes both without touching product behavior.enable_app_endpointsignature drift — feat(metrics): server-side product-event counters with app-version labeling #15099 ("feat(metrics): server-side product-event counters with app-version labeling") added a requiredrequest: Requestparameter torouters.apps.enable_app_endpointso it can callrecord_product_event(..., request=request)for telemetry.tests/unit/test_app_enable_install_count.pyandtests/unit/test_setup_completed_url_uid_query.pycall the endpoint function directly and still used the pre-feat(metrics): server-side product-event counters with app-version labeling #15099 two-argument call, so both files raisedTypeError: enable_app_endpoint() missing 1 required positional argument: 'request'on main. Fix: pass a minimal ASGI-scopestarlette.requests.Requestdouble (empty headers) at each call site —record_product_eventonly readsrequest.headersand is fail-open by design, andtests/unit/test_product_metrics.pyalready constructs aRequestthe same way for this module. No endpoint behavior changed.app/lib/backend/http/api/speech_profile.dart::_errorDetail, a helper called fromuploadProfilethat does a rawjsonDecode+ field access on an error response body to pull out adetailstring for the exception message.tests/unit/test_app_client_schema_inventory.py::test_inventory_openapi_route_response_decode_migration_completewalks each OpenAPI-backed route function plus its called-helper ranges and asserts zero raw (non-generated) response-decode sites;_errorDetail's two sites got attributed touploadProfileand counted as unmigrated response decoding._errorDetailinspects a bounded error envelope to choose an application control path (surface the backend's error message) — it does not decode an OpenAPI response DTO — which is exactly the shapescripts/inventory_app_client_schemas.pyalready carves out viaNON_REST_RESPONSE_DECODER_FUNCTIONS(the existing member,conversations.dart::isSyncRecoveryWindowExceededResponse, is the same kind of helper). Fix: addspeech_profile.dart::_errorDetailto that allowlist. No test assertion was weakened or deleted; the migration-complete gate still fails on any actual unmigrated response decode.Neither PR's own CI run could have caught this: each ran the full backend unit suite against its own base commit before any of the other ~20 PRs existed on
main, and GitHub Actions doesn't re-run a merged PR's checks against the post-merge tree of unrelated PRs merged around the same time.Root cause
Two independently-reviewed, independently-green PRs (#15099, #15058) each changed a production call surface (an endpoint's parameter list; a Dart helper's presence) that a test elsewhere in the tree had to track, and their own diffs' test selection had no way to see the other PR's diff. Merging ~20 such PRs within five minutes compounded this into two concrete breakages once they were combined on
main.Failure-Class
FC-fixture-mock-signature-drift's violated contract ("a test's expectations of a production call surface must be updated in the same window the production surface changes, or the shared CI shard goes red for every open PR") is the closest existing class for fix 1 (a direct call site, not a mock, missed a new required parameter) and the same root shape for fix 2 (a static classification registry missed a newly introduced, legitimately-exempt code pattern). No existing class names the multi-PR-merge-burst mechanism itself; per repo guidance this is filed under the closest matching class rather than inventing a new one.Failure-Class: FC-fixture-mock-signature-drift
Invariants
scripts/pr-preflight --suggestreports no product invariants affected by this change (test files and a static analysis script only; noproduct/invariants/path globs are touched).Verification
All commands run from
backend/in a fresh worktree (/Volumes/Ephemeral/scratch/worktrees/omi/main-unit-tests-red) against auv-built Python 3.11.15.venv(scripts/sync-python-deps.sh), viabash test-preflight.sh(26 checks, 0 failed) thenbash test.shwithBACKEND_UNIT_TEST_FILE_LIST:tests/unit/test_app_enable_install_count.py— 3 passed (was: 2 failed with theTypeErrorabove)tests/unit/test_setup_completed_url_uid_query.py— 4 passed (was: 2 of 4 parametrized cases failed with the sameTypeError; theoauth-tokenparametrization was never affected)tests/unit/test_app_client_schema_inventory.py— 12 passed (was: 1 failed,test_inventory_openapi_route_response_decode_migration_complete)Also ran the full
scripts/run-unit-ci.sh --allcontract locally to check for other collateral damage from the same merge burst beyond the two known failures.Formatted with
scripts/backend-python-format --write(repo-pinned invocation; reformatted one line-length wrap, no semantic change).🤖 Generated with Claude Code