Skip to content

fix(backend): unbreak Backend Unit Tests on main (merge-train collision) - #15219

Merged
Git-on-my-level merged 2 commits into
mainfrom
fix/main-backend-unit-tests-red
Sep 20, 2026
Merged

Git-on-my-level merged 2 commits into
mainfrom
fix/main-backend-unit-tests-red

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Sep 20, 2026 •

Copy link
Copy Markdown
Member

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.

  1. enable_app_endpoint signature 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 required request: Request parameter to routers.apps.enable_app_endpoint so it can call record_product_event(..., request=request) for 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 pre-feat(metrics): server-side product-event counters with app-version labeling #15099 two-argument call, so both files raised TypeError: enable_app_endpoint() missing 1 required positional argument: 'request' on main. Fix: pass a minimal ASGI-scope starlette.requests.Request double (empty headers) at each call site — record_product_event only reads request.headers and is fail-open by design, and tests/unit/test_product_metrics.py already constructs a Request the same way for this module. No endpoint behavior changed.
  2. App-client schema inventory false positive — fix(app): recognize a too-short speech profile upload from the backend detail again #15058 ("fix(app): recognize a too-short speech profile upload from the backend detail again"), merged in the same burst, 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 pull out a detail string for the exception message. tests/unit/test_app_client_schema_inventory.py::test_inventory_openapi_route_response_decode_migration_complete walks 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 to uploadProfile and counted as unmigrated response decoding. _errorDetail inspects 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 shape scripts/inventory_app_client_schemas.py already carves out via NON_REST_RESPONSE_DECODER_FUNCTIONS (the existing member, conversations.dart::isSyncRecoveryWindowExceededResponse, is the same kind of helper). Fix: add speech_profile.dart::_errorDetail to 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 --suggest reports no product invariants affected by this change (test files and a static analysis script only; no product/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 a uv-built Python 3.11.15 .venv (scripts/sync-python-deps.sh), via bash test-preflight.sh (26 checks, 0 failed) then bash test.sh with BACKEND_UNIT_TEST_FILE_LIST:

  • tests/unit/test_app_enable_install_count.py — 3 passed (was: 2 failed with the TypeError above)
  • tests/unit/test_setup_completed_url_uid_query.py — 4 passed (was: 2 of 4 parametrized cases failed with the same TypeError; the oauth-token parametrization 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 --all contract 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

Review in cubic

Git-on-my-level and others added 2 commits September 21, 2026 00:23
#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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant