Skip to content
Flutter SDK

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).

FieldMeaning
statusHTTP status. 0 for a local problem (no response); isLocal is then true.
codeStable machine code, for example FEATURE_UNAVAILABLE or RATE_LIMITED. Branch on this, not on title.
title, detailHuman-readable text from the server
requestIdThe server's x-request-id. Show it on support screens and include it in bug reports.
retryAfterSecondsFrom retry_after_seconds, or else the Retry-After header
fieldErrorsList<FieldError> (field, code, message) for validation errors
isRetryableNETWORK_ERROR, TIMEOUT, 429, 502, 503, 504, but not FEATURE_UNAVAILABLE
nextActionWhat 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.

Dart
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:

ConditionNextAction
code == APP_UPDATE_REQUIREDupdateApp
status == 401signIn
status == 429waitForCooldown
status == 400 or 422editInput
ACCOUNT_CONFLICT, PURCHASE_OWNED_BY_OTHER_ACCOUNTsignInToExistingAccount
ALREADY_OWNEDrestorePurchase
FEATURE_UNAVAILABLEuseAnotherMethod
any other retryable problemretry
status >= 500contactSupport
otherwisenone

Local codes

These come from the SDK itself, with status == 0:

CodeRaised by
NETWORK_ERROR, TIMEOUTTransport (20 s timeout per attempt)
SESSION_REQUIREDAn authenticated call with no session
SESSION_TOKEN_MISSING, SCOPE_MISMATCHSign-in response with no token, or for another app or environment
APP_ENVIRONMENT_MISMATCH, APP_UPDATE_REQUIREDAppCore.init
FEATURE_UNAVAILABLEDisabled capability (core.commerce, core.messaging, disabled auth method)
INVALID_CODE_FORMATverifyOtp 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

ExceptionWhen
ArgumentErrorAppCoreManifest.validate (non-https release URL, local host in release, secret-looking URL, unknown environment); analytics.track with an unregistered event or property
StateErrorentitlements.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;
  • nextAction is useAnotherMethod;
  • 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.

CallRetried automatically?Idempotency key
All GETs (including AppCore.init)Yes—
auth.requestOtp, verifyOtp, signInWithSocial, startContactLink, verifyContactLink, socialLinkProofNoRandom per call
commerce.purchase (purchase intent)NoRandom per call
auth.link, auth.unlinkYesDerived from provider + proof / identity id
Purchase verifyYes, and again on store redeliveryDerived from provider + transaction reference
commerce.restoreYesDerived from provider + sorted references
messaging.registerDevice, device detachYesDerived from installation, token, permission, user / installation
messaging.markReadYesDerived from item id
Analytics batchYesDerived from the batch's event ids
auth.logout, privacy.setConsent, requestExport, requestAccountDeletion, messaging.savePreferencesYes, within the callRandom 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.

Dart
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.