Flutter errors and retries
AppCoreProblem, NextAction, FEATURE_UNAVAILABLE, and the retry and idempotency behaviour of each Flutter SDK call.
On this page
AppCoreProblem
Every failed call throws AppCoreProblem. It is a typed view of the canonical application/problem+json body
(Problem.schema.json).
| Field | Meaning |
|---|---|
status | HTTP status. 0 for a local problem (no response); isLocal is then true. |
code | Stable machine code, for example FEATURE_UNAVAILABLE or RATE_LIMITED. Branch on this, not on title. |
title, detail | Human-readable text from the server |
requestId | The server's x-request-id. Show it on support screens and include it in bug reports. |
retryAfterSeconds | From retry_after_seconds, or else the Retry-After header |
fieldErrors | List<FieldError> (field, code, message) for validation errors |
isRetryable | NETWORK_ERROR, TIMEOUT, 429, 502, 503, 504, but not FEATURE_UNAVAILABLE |
nextAction | What the UI should offer next (below) |
A response body that is not a canonical Problem becomes code HTTP_<status>, with the title "Unexpected response".
The raw body is never shown, because it could contain provider diagnostics.
try {
await core.auth.requestOtp(method: 'email_otp', destination: email);
} on AppCoreProblem catch (p) {
switch (p.nextAction) {
case NextAction.waitForCooldown:
showCooldown(p.retryAfterSeconds);
case NextAction.useAnotherMethod:
showOtherSignInMethods();
case NextAction.editInput:
showFieldErrors(p.fieldErrors);
default:
showError(p.title, requestId: p.requestId);
}
}NextAction
Checked in this order:
| Condition | NextAction |
|---|---|
code == APP_UPDATE_REQUIRED | updateApp |
status == 401 | signIn |
status == 429 | waitForCooldown |
status == 400 or 422 | editInput |
ACCOUNT_CONFLICT, PURCHASE_OWNED_BY_OTHER_ACCOUNT | signInToExistingAccount |
ALREADY_OWNED | restorePurchase |
FEATURE_UNAVAILABLE | useAnotherMethod |
| any other retryable problem | retry |
status >= 500 | contactSupport |
| otherwise | none |
Local codes
These come from the SDK itself, with status == 0:
| Code | Raised by |
|---|---|
NETWORK_ERROR, TIMEOUT | Transport (20 s timeout per attempt) |
SESSION_REQUIRED | An authenticated call with no session |
SESSION_TOKEN_MISSING, SCOPE_MISMATCH | Sign-in response with no token, or for another app or environment |
APP_ENVIRONMENT_MISMATCH, APP_UPDATE_REQUIRED | AppCore.init |
FEATURE_UNAVAILABLE | Disabled capability (core.commerce, core.messaging, disabled auth method) |
INVALID_CODE_FORMAT | verifyOtp with a code that is not 6 digits |
Common server codes are INVALID_REQUEST, UNAUTHENTICATED, FORBIDDEN, NOT_FOUND, CONFLICT,
STALE_VERSION, PAYLOAD_TOO_LARGE, RATE_LIMITED, FEATURE_UNAVAILABLE, NOT_IMPLEMENTED and INTERNAL.
Modules add their own codes, for example PURCHASE_OWNED_BY_OTHER_ACCOUNT. An ID from another app or user returns
the same 404 as an ID that does not exist.
Exceptions that are not AppCoreProblem
| Exception | When |
|---|---|
ArgumentError | AppCoreManifest.validate (non-https release URL, local host in release, secret-looking URL, unknown environment); analytics.track with an unregistered event or property |
StateError | entitlements.refresh() received a snapshot for a different user |
FEATURE_UNAVAILABLE
503 FEATURE_UNAVAILABLE means "not configured", not "temporarily down". The backend returns it when a capability's
provider is missing or not ready. Examples: email OTP with no email sender, Apple browser sign-in with no Services ID,
or public config not yet published. The backend never fakes success.
The SDK treats it as a configuration state:
- it is never retried;
nextActionisuseAnotherMethod;- the SDK raises the same code locally when public config says the capability is off, without sending the request.
Hide or disable the feature. Do not show a retry loop.
Retries and idempotency
Every request carries a fresh x-request-id and x-appcore-sdk: flutter/<version>. Every effect carries an
Idempotency-Key. Retried calls get up to 4 attempts in total. The delay is 300 ms × 2^(attempt−1) plus jitter,
capped at 10 s, or retry_after_seconds (capped at 60 s) when the server sends it. Only retryable problems are
retried.
| Call | Retried automatically? | Idempotency key |
|---|---|---|
All GETs (including AppCore.init) | Yes | — |
auth.requestOtp, verifyOtp, signInWithSocial, startContactLink, verifyContactLink, socialLinkProof | No | Random per call |
commerce.purchase (purchase intent) | No | Random per call |
auth.link, auth.unlink | Yes | Derived from provider + proof / identity id |
| Purchase verify | Yes, and again on store redelivery | Derived from provider + transaction reference |
commerce.restore | Yes | Derived from provider + sorted references |
messaging.registerDevice, device detach | Yes | Derived from installation, token, permission, user / installation |
messaging.markRead | Yes | Derived from item id |
| Analytics batch | Yes | Derived from the batch's event ids |
auth.logout, privacy.setConsent, requestExport, requestAccountDeletion, messaging.savePreferences | Yes, within the call | Random per call (a new call is a new request) |
"Derived" keys are the same after an app restart. A purchase verified after a crash, or a restore repeated by the user, is therefore recognised by the server as the same request.
Calling an endpoint the SDK does not wrap
core.transport is the same Transport the modules use. It adds the bearer token, request id, problem parsing and
token rotation.
final r = await core.transport.send('GET', '/v1/commerce/subscriptions/$subscriptionId');
final subscription = Subscription.fromJson(r.json);For an effect, pass idempotencyKey: (use stableKey(namespace, parts) for a key that survives restarts, or
randomId('idem_')) and retry: RetryPolicy.idempotent only if the contract marks the endpoint as idempotent.