lingochamp/FileDownloader · error · IllegalStateException

Can't restore the snapshot because unknown status

Error message

Can't restore the snapshot because unknown status: %d

What it means

Raised in MessageSnapshot.createFromParcel when the status int read from the Parcel does not match any known FileDownloadStatus constant, so no snapshot class can be constructed for it. Typically means the parcel was written by a different/newer version of the library whose status codes this version does not recognize, or the parcel data is corrupted/misaligned.

Solutions

  1. Keep the FileDownloader library version identical between the process that wrote the parcel and the one restoring it (e.g. after an app update, clear in-flight download state)
  2. If you forward parcels between processes, ensure both use the same library version and the parcel is written with writeParcelable and read in matching order
  3. Discard stale download snapshots on upgrade and re-query download state from the database instead of restoring old parcels
  4. Add handling for unknown status codes (default branch) so restoration fails gracefully instead of with an error
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at library/src/main/java/com/liulishuo/filedownloader/message/MessageSnapshot.java:185 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of lingochamp/FileDownloader@6237a8cac1 (2026-09-08). Data as JSON: /api/errors/b800b98faf11975d. Report an issue: GitHub.

Appendix: source

Thrown at library/src/main/java/com/liulishuo/filedownloader/message/MessageSnapshot.java:185

                    } else {
                        snapshot = new SmallMessageSnapshot.CompletedSnapshot(source);
                    }
                    break;
                case FileDownloadStatus.warn:
                    if (largeFile) {
                        snapshot = new LargeMessageSnapshot.WarnMessageSnapshot(source);
                    } else {
                        snapshot = new SmallMessageSnapshot.WarnMessageSnapshot(source);
                    }
                    break;
                default:
                    snapshot = null;
            }

            if (snapshot != null) {
                snapshot.isLargeFile = largeFile;
            } else {
                throw new IllegalStateException("Can't restore the snapshot because unknown "
                        + "status: " + status);
            }

            return snapshot;
        }

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

    public static class NoFieldException extends IllegalStateException {
        NoFieldException(String methodName, MessageSnapshot snapshot) {
            super(FileDownloadUtils.formatString("There isn't a field for '%s' in this message"
                            + " %d %d %s",
                    methodName, snapshot.getId(), snapshot.getStatus(),
                    snapshot.getClass().getName()));

View on GitHub (pinned to 6237a8cac1)