SDK error · code 21

invalidSubscriberAttributesError (error code 21): Invalid subscriber attributes

What it means

invalidSubscriberAttributesError (code 21) means the server could not save one or more customer attributes, reported as backend code 7263 or 7264. The error lists the failing keys. Fix or drop those values, for example an invalid $email. The valid attributes in the same request are still saved, and the error never blocks a purchase.

Code

21

iOS (Swift)

ErrorCode.invalidSubscriberAttributesError

Android (Kotlin)

PurchasesErrorCode.InvalidSubscriberAttributesError

Causes

Why the SDK returns invalidSubscriberAttributesError

  • The backend answered 7263 (invalid subscriber attributes) or 7264 (invalid subscriber attributes body), which both SDKs map here (BackendErrorCode.swift, errors.kt).
  • A reserved attribute, one whose key starts with $, has a bad value, for example an email address that is not an email.
  • A custom attribute has a key or value the server refuses.
  • On iOS, the failing keys and messages come back in the error's attribute_errors entry in userInfo (ErrorDetails.swift).
Backend codeMeaning
7263Invalid subscriber attributes: one or more attributes could not be saved.
7264Invalid subscriber attributes body.

Fix

How to fix invalidSubscriberAttributesError

  1. 01

    Read which keys failed

    On iOS read attribute_errors from userInfo, or subscriberAttributesErrors on the public error. It maps each failing key to a message.

  2. 02

    Validate before you set

    Check that $email looks like an email address, and trim values, before you call setEmail or setAttributes.

  3. 03

    Drop or fix the value

    Remove the failing key, or send a valid value. The next sync posts the corrected attributes.

  4. 04

    Do not block your UI on it

    Attribute sync runs in the background. Log the failing keys and carry on.

In your app

How to handle it in code

  • Do not retry the same values. They will fail the same way.
  • Do not show this to customers. It is a data-quality problem, not something they can fix.
  • On iOS, a failure for a custom key (one without $) counts as a blocking error for the combined attributes-and-offerings sync, but a failure for a reserved $ key does not (Purchases.swift). Do not grant or withhold access based on it.
Match the errorSwift · Kotlin
// Swift
do {
  let result = try await Purchases.shared.purchase(package: package)
} catch let error as ErrorCode where error == .invalidSubscriberAttributesError {
  // handle invalid subscriber attributes
}

// Kotlin
if (error.code == PurchasesErrorCode.InvalidSubscriberAttributesError) { /* ... */ }

On RevenueDot: RevenueDot validates $email. If it is not an email address, it answers HTTP 400 with code 7263, lists the key in attribute_errors, and still saves every other attribute in the request.

FAQ

invalidSubscriberAttributesError: questions people ask

Which attributes does RevenueDot reject?

It checks $email and answers 400 with code 7263 when the value is not an email address. It saves the other attributes in the same request and lists the rejected key in attribute_errors.

Does invalidSubscriberAttributesError stop a purchase?

No. Attributes sync separately from purchases. A failed attribute does not block a purchase or an entitlement.

How do I check for invalidSubscriberAttributesError in React Native and Flutter?

In React Native, compare error.code with PURCHASES_ERROR_CODE.INVALID_SUBSCRIBER_ATTRIBUTES_ERROR. In Flutter, convert the PlatformException with PurchasesErrorHelper.getErrorCode(e) and compare the result with PurchasesErrorCode.invalidSubscriberAttributesError.

Get started

Keep the RevenueCat SDK. Change the backend.

RevenueDot answers the same SDK calls with the same error codes. Start free on RevenueDot Cloud, free up to $10,000 a month in tracked revenue.

Already have an account? Sign in · Prefer your own servers? Self-host free