Skip to content

Classify register/complete "Invalid signature" by API code, not message text #911

Description

@marassteiner

Summary

RealUnitRegistrationService.completeRegistration decides whether a 400 is a content rejection (RegistrationRejectedException) or a generic ApiException by comparing error.message to the free-text string 'Invalid signature'. That mapping should use a stable API error code once the backend exposes one.

Evidence

  • lib/packages/service/dfx/real_unit_registration_service.dart:215error.message != 'Invalid signature'
  • test/packages/service/dfx/real_unit_registration_service_test.dart:315 — the test pins the same literal
  • lib/packages/service/dfx/exceptions/api_exception.dart:15-21 already classifies structured codes (KYC_LEVEL_REQUIRED, REGISTRATION_REQUIRED)

Found while reviewing #910. That PR is correct to stop mapping this 400 to "check your entries"; the string match is only a brittle contract, not a regression of the #905 fix.

Suggested follow-up

  1. Backend: return a stable code such as INVALID_SIGNATURE on POST /v1/realunit/register/complete.
  2. App: classify on error.code (or a dedicated ApiException subclass via fromJson).
  3. If a new exception type is added, enumerate it in exception_surface_test.dart in the same PR.

Not a merge blocker for #910: if the message text ever changes, the UI falls back to the previous generic failure path rather than blocking registration.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions