{"record":{"id":"8e87caadb50108be","repo":"google/ExoPlayer","slug":"unknown-ratingtype-ratingtype","errorCode":null,"errorMessage":"Unknown RatingType: ${ratingType}","messagePattern":"Unknown RatingType: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"library/common/src/main/java/com/google/android/exoplayer2/Rating.java","lineNumber":88,"sourceCode":"\n  /** Object that can restore a {@link Rating} from a {@link Bundle}. */\n  public static final Creator<Rating> CREATOR = Rating::fromBundle;\n\n  private static Rating fromBundle(Bundle bundle) {\n    @RatingType\n    int ratingType = bundle.getInt(FIELD_RATING_TYPE, /* defaultValue= */ RATING_TYPE_UNSET);\n    switch (ratingType) {\n      case RATING_TYPE_HEART:\n        return HeartRating.CREATOR.fromBundle(bundle);\n      case RATING_TYPE_PERCENTAGE:\n        return PercentageRating.CREATOR.fromBundle(bundle);\n      case RATING_TYPE_STAR:\n        return StarRating.CREATOR.fromBundle(bundle);\n      case RATING_TYPE_THUMB:\n        return ThumbRating.CREATOR.fromBundle(bundle);\n      case RATING_TYPE_UNSET:\n      default:\n        throw new IllegalArgumentException(\"Unknown RatingType: \" + ratingType);\n    }\n  }\n}\n","sourceCodeStart":70,"sourceCodeEnd":92,"githubUrl":"https://github.com/google/ExoPlayer/blob/dd430f7053a1a3958deea3ead6a0565150c06bfc/library/common/src/main/java/com/google/android/exoplayer2/Rating.java#L70-L92","documentation":"Rating.CREATOR.fromBundle reads a rating-type discriminator int from the Bundle; if it is not one of the known constants (heart, percentage, star, thumb) — including UNSET — the static factory throws IllegalArgumentException. It means the Bundle was not produced by a Rating subclass's toBundle, or the persisted/tunneled data is corrupt or from an incompatible version.","triggerScenarios":"Rating.fromBundle(bundle) where bundle.getInt(FIELD_RATING_TYPE) is missing or an unknown value. Occurs with hand-built Bundles, data restored from remote processes/backups written by a different Media3 version, or process-death state restoration of a malformed bundle.","commonSituations":"Passing a MediaMetadata or session rating Bundle across IPC from a non-Media3 producer; reading ratings from persistence where the int was never written; version skew where new rating types are read by an older library.","solutions":["Only pass Bundles created by HeartRating/PercentageRating/StarRating/ThumbRating.toBundle() into Rating.fromBundle.","When reading untrusted Bundles, check the discriminator first: int t = bundle.getInt(FIELD_RATING_TYPE); verify it is 1-4 before calling fromBundle.","If persisting ratings, store the typed object's fields yourself or round-trip through the same Media3 version.","Align Media3 versions across processes (app vs. media session controller) to avoid unknown type constants."],"exampleFix":"// before\nRating r = Rating.CREATOR.fromBundle(incomingBundle); // throws on unknown type\n\n// after\nint type = incomingBundle.getInt(Rating.FIELD_RATING_TYPE, Rating.RATING_TYPE_UNSET);\nRating r = (type == Rating.RATING_TYPE_HEART || type == Rating.RATING_TYPE_PERCENTAGE\n    || type == Rating.RATING_TYPE_STAR || type == Rating.RATING_TYPE_THUMB)\n        ? Rating.CREATOR.fromBundle(incomingBundle) : null;","handlingStrategy":"type-guard","validationCode":"int t = bundle.getInt(Rating.FIELD_RATING_TYPE, Rating.RATING_TYPE_UNSET);\nboolean known = t == Rating.RATING_TYPE_HEART || t == Rating.RATING_TYPE_PERCENTAGE\n    || t == Rating.RATING_TYPE_STAR || t == Rating.RATING_TYPE_THUMB;","typeGuard":"static boolean isKnownRatingBundle(Bundle b) {\n  int t = b.getInt(Rating.FIELD_RATING_TYPE, Rating.RATING_TYPE_UNSET);\n  return t == Rating.RATING_TYPE_HEART || t == Rating.RATING_TYPE_PERCENTAGE\n      || t == Rating.RATING_TYPE_STAR || t == Rating.RATING_TYPE_THUMB;\n}","tryCatchPattern":"try { rating = Rating.CREATOR.fromBundle(b); } catch (IllegalArgumentException e) { rating = null; /* treat as unrated */ }","preventionTips":["Only feed Bundles produced by Rating.toBundle() back into fromBundle().","Guard unknown rating types before deserializing untrusted/IPC Bundles.","Keep Media3 versions aligned across processes to avoid new unrecognized type constants."],"tags":["rating","bundle","serialization","media3","validation"],"backgroundTag":null,"analyzedSha":"dd430f7053a1a3958deea3ead6a0565150c06bfc","analyzedAt":"2026-08-14T12:22:02.982Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}