microg/GmsCore · error · PublicKeyCredentialType.UnsupportedPublicKeyCredTypeException

PublicKeyCredentialType ${type} not supported

Error message

PublicKeyCredentialType ${type} not supported

What it means

PublicKeyCredentialType.fromString() maps a credential type string ("public-key") to the enum; any other value throws UnsupportedPublicKeyCredTypeException. WebAuthn currently defines only "public-key", so this fires on typos or future/unknown type identifiers.

Source

Thrown at play-services-fido/src/main/java/com/google/android/gms/fido/fido2/api/common/PublicKeyCredentialType.java:51

        return value;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(toString());
    }

    @Hide
    public static PublicKeyCredentialType fromString(String type) throws UnsupportedPublicKeyCredTypeException {
        for (PublicKeyCredentialType value : values()) {
            if (value.value.equals(type)) return value;
        }
        throw new UnsupportedPublicKeyCredTypeException("PublicKeyCredentialType " + type + " not supported");
    }

    public static Creator<PublicKeyCredentialType> CREATOR = new Creator<PublicKeyCredentialType>() {
        @Override
        public PublicKeyCredentialType createFromParcel(Parcel source) {
            try {
                return PublicKeyCredentialType.fromString(source.readString());
            } catch (UnsupportedPublicKeyCredTypeException e) {
                throw new RuntimeException(e);
            }
        }

        @Override
        public PublicKeyCredentialType[] newArray(int size) {
            return new PublicKeyCredentialType[size];
        }
    };

View on GitHub (pinned to 157c9d86ac)

Solutions

  1. Use exactly "public-key" for the type field.
  2. Validate the type string against PublicKeyCredentialType values before calling fromString.
  3. Filter out credential entries with unknown types before parsing each one.

Example fix

// before
var type = PublicKeyCredentialType.fromString(json.getString("type"));
// after
String t = json.optString("type", "public-key");
var type = "public-key".equals(t) ? PublicKeyCredentialType.fromString(t) : null;
Defensive patterns

Strategy: try-catch

Validate before calling

boolean valid = "public-key".equals(typeStr);

Try / catch

try { type = PublicKeyCredentialType.fromString(t); } catch (UnsupportedPublicKeyCredTypeException e) { skipCredential(); }

Prevention

When it happens

Trigger: Calling fromString with anything but "public-key": e.g. "Public-Key" (case-sensitive), "webauthn", "", or a JSON credential object whose "type" field is missing/garbled.

Common situations: Malformed JSON from a relying-party server; test fixtures with wrong case; future credential types emitted by newer authenticators that this library predates.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of microg/GmsCore@157c9d86ac (2026-09-06). Data as JSON: /api/errors/cda77f4ac0a127ec. Report an issue: GitHub.