Skip to content

fix(app): recognize a too-short speech profile upload from the backend detail again - #15058

Merged
kodjima33 merged 1 commit into
BasedHardware:mainfrom
singhharsh1708:fix/app-speech-profile-too-short-detail
Sep 20, 2026
Merged

kodjima33 merged 1 commit into
BasedHardware:mainfrom
singhharsh1708:fix/app-speech-profile-too-short-detail

Conversation

@singhharsh1708

@singhharsh1708 singhharsh1708 commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #15057

#14514 switched uploadProfile to throw SpeechProfileUploadException(statusCode), but _isTooShortUploadError still matched the backend's detail text against error.toString(), which is now just Speech profile upload failed (400). A too-short recording was retried three times and ended as UPLOAD_FAILED instead of showing the "not enough speech" dialog.

The exception now carries the backend detail (parsed from the error body when present), and the classifier reads it for SpeechProfileUploadException and falls back to toString() for anything else.

Two tests added to test/providers/speech_profile_provider_test.dart throw the exception with each backend message. With main's classifier both fail with Expected: true, Actual: <false> for tooShort. With the fix both pass, the upload is attempted once, and the rest of the file still passes.

cd app
flutter test test/providers/speech_profile_provider_test.dart   # +29: All tests passed!
bash test.sh                                                     # +2399 ~5: All tests passed!
bash scripts/analyze_ratchet.sh                                  # Analyzer ratchet passed.

Failure-Class: FC-provider-http-error-format

Review in cubic

@Git-on-my-level

Copy link
Copy Markdown
Member

Verified the full regression chain — thanks for the clean fix and the focused tests.

  • app/lib/backend/http/api/speech_profile.dart — _errorDetail parses the backend error body and only surfaces a detail that is a JSON map with a string value; every decode failure falls back to null, so non-JSON or unexpectedly-shaped bodies behave exactly as before. SpeechProfileUploadException grows an optional detail without breaking the const constructor or existing catch sites. One optional nit: toString() still only reports the status code, so a caught-but-unclassified exception logs as Speech profile upload failed (400) — appending the detail there would make future log-only diagnoses easier.
  • app/lib/providers/speech_profile_provider.dart — the classifier now reads error.detail for SpeechProfileUploadException and keeps error.toString() for anything else, so the timeout path and generic errors are unaffected. I checked the backend contract: backend/routers/speech_profile.py returns exactly "Audio duration is invalid (must be 5-180 seconds)" and "Audio is empty" as FastAPI detail strings, which is the shape _errorDetail decodes — the substrings match.
  • app/test/providers/speech_profile_provider_test.dart — the two new cases throw the exception with each backend message and assert tooShort is reported with exactly one upload attempt, which pins down the actual regression (no more 3× retry of a too-short recording) rather than just the exception shape. Good coverage.

I also confirmed the other SpeechProfileUploadException catch site (app/lib/pages/onboarding/guided_voice_io.dart) only branches on statusCode, so it needs no change here.

Checks are green. This restores the intended "not enough speech" dialog behavior from before #14514; leaving the merge call to the maintainers.

🤖 Automated review on behalf of the maintainers.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added positive-signal Automation verified a genuine fix/quality contribution flutter flutter work labels Sep 20, 2026

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes too-short speech-profile classifier regression from #14514, scoped diff, test added demonstrating pre/post behavior. 5/5.

@kodjima33
kodjima33 merged commit 16bfd45 into BasedHardware:main Sep 20, 2026
43 of 44 checks passed
Git-on-my-level added a commit that referenced this pull request Sep 20, 2026
…on) (#15219)

* fix(backend): pass a request double to enable_app_endpoint in unit tests

#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]>

* fix(backend): classify speech_profile's _errorDetail as a bounded error-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]>

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
kodjima33 pushed a commit that referenced this pull request Sep 21, 2026
…model (#15187)

The raw jsonDecode I added in #15058 made uploadProfile report raw response decode sites, which fails test_inventory_openapi_route_response_decode_migration_complete and takes every backend shard red on main. misc_wire.GeneratedErrorResponse already models that body.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flutter flutter work positive-signal Automation verified a genuine fix/quality contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bounty proposal] fix(app): a too-short speech profile recording is retried 3 times and never shows the "not enough speech" dialog ($25 proposed)

3 participants