lingochamp/FileDownloader · error · IllegalArgumentException
can't create the block complete message for id
Error message
can't create the block complete message for id[%d], status[%d]
What it means
FileDownloader throws this IllegalArgumentException from the BlockCompleteMessageImpl constructor when the snapshot passed in is not in the 'completed' status. A block-complete message can only be built from a completed snapshot, since it wraps the completed snapshot to later transmit it; the constructor fails fast on any other status (pending, progress, error, warn, etc.).
Solutions
- Check the snapshot status with snapshot.getStatus() and only construct BlockCompleteMessageImpl when it equals FileDownloadStatus.completed
- Log snapshot.getStatus() and getId() at the call site to find where the wrong snapshot is being passed
- Ensure the completed snapshot is delivered before the block-complete flow is triggered (do not pre-construct with a progress snapshot)
- Update the library: newer versions of FileDownloader handle block-complete conversion internally without exposing this path
Example fix
// before
BlockCompleteMessage msg = new BlockCompleteMessage.BlockCompleteMessageImpl(anySnapshot);
// after
if (anySnapshot.getStatus() == FileDownloadStatus.completed) {
BlockCompleteMessage msg = new BlockCompleteMessage.BlockCompleteMessageImpl(anySnapshot);
} Defensive patterns
Strategy: validation
Validate before calling
if (snapshot != null && snapshot.getStatus() != FileDownloadStatus.completed) {
throw new IllegalStateException("BlockCompleteMessage requires a completed snapshot, got status=" + snapshot.getStatus());
} Type guard
boolean isCompletedSnapshot(MessageSnapshot s) {
return s != null && s.getStatus() == FileDownloadStatus.completed;
} Try / catch
try {
BlockCompleteMessage msg = new BlockCompleteMessage.BlockCompleteMessageImpl(snapshot);
} catch (IllegalArgumentException e) {
Log.e(TAG, "Cannot build block complete message: " + e.getMessage());
} Prevention
- Always verify getStatus() == FileDownloadStatus.completed before constructing a block-complete message
- Never wrap progress/error/warn snapshots in BlockCompleteMessageImpl
- Let the library create block-complete messages internally instead of doing it manually
- Log snapshot id and status when intercepting lifecycle messages
When it happens
Trigger: Calling new BlockCompleteMessage.BlockCompleteMessageImpl(snapshot) with a snapshot whose getStatus() != FileDownloadStatus.completed — e.g. wrapping a progress or error snapshot instead of the completed one.
Common situations: Custom code or patched library code that intercepts download lifecycle messages and manually constructs a block-complete message from the wrong snapshot; internal callers receiving a snapshot of an unexpected status from a custom MessageStation/Service layer.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- fetched length[ ] != content length[ ], range[ , ) offset[…
- listener must not be null!
- event must not be null!
- getThrowable
- getRetryingTimes
AI-assisted analysis of lingochamp/FileDownloader@6237a8cac1 (2026-09-08).
Data as JSON: /api/errors/bb07391180b2d599.
Report an issue: GitHub.
Appendix: source
Thrown at library/src/main/java/com/liulishuo/filedownloader/message/BlockCompleteMessage.java:39
/**
* The interface of block complete message.
*
* @see SmallMessageSnapshot
* @see LargeMessageSnapshot
*/
public interface BlockCompleteMessage {
MessageSnapshot transmitToCompleted();
class BlockCompleteMessageImpl extends MessageSnapshot implements BlockCompleteMessage {
private final MessageSnapshot mCompletedSnapshot;
public BlockCompleteMessageImpl(MessageSnapshot snapshot) {
super(snapshot.getId());
if (snapshot.getStatus() != FileDownloadStatus.completed) {
throw new IllegalArgumentException(FileDownloadUtils.formatString(
"can't create the block complete message for id[%d], status[%d]",
snapshot.getId(), snapshot.getStatus()));
}
this.mCompletedSnapshot = snapshot;
}
@Override
public MessageSnapshot transmitToCompleted() {
return this.mCompletedSnapshot;
}
@Override
public byte getStatus() {
return FileDownloadStatus.blockComplete;
}
}
}View on GitHub (pinned to 6237a8cac1)