immich-app/immich · error · BadRequestException
Asset not found
Error message
Asset not found
What it means
assetService.get loads an asset with relations (stack, edits, tags, etc.) and throws BadRequestException('Asset not found') when the repository returns null. It is called by update (which returns this.get) as well as directly, so both read and update flows surface this message. Note it is a 400, not a 404, despite being a missing-resource error.
Solutions
- Verify the asset exists and is accessible: GET /api/assets/:id with the same credentials.
- Refresh the client's asset list to drop deleted/stale ids.
- For shared-link flows, ensure the asset is part of the shared link's album.
- If you own the id generation, validate the UUID before calling (a truncated id never matches).
Example fix
// before
await api.updateAsset(id, { description: 'x' }); // stale id
// after
const exists = await api.getAssetInfo(id).catch(() => null);
if (exists) await api.updateAsset(id, { description: 'x' });
else await refreshAssetList(); Defensive patterns
Strategy: try-catch
Validate before calling
const asset = await api.getAssetInfo(id).catch(() => null);
if (!asset) throw new Error(`Asset ${id} missing or inaccessible`); Try / catch
try { await api.updateAsset(id, dto); } catch (e) { if (String(e).includes('Asset not found')) { removeFromCache(id); return; } throw e; } Prevention
- Re-fetch asset lists after deletes to purge stale ids
- Validate UUID format before calling
- For shared links, only reference assets inside the shared album
When it happens
Trigger: PUT /api/assets/:id (update) or the internal get() call with an id that does not exist, was deleted, or belongs to another user/album not visible via the auth context (e.g. shared link without access).
Common situations: Stale client caches holding ids of deleted assets; copying ids between Immich instances; shared-link users attempting operations on assets outside the link; races with trash emptying.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- Asset not found
- Asset not found or asset is not a video
- Both assets must exist
- Invalid assetId for feature face or asset is offline
- Invalid user
AI-assisted analysis of immich-app/immich@e55ac299a4 (2026-09-15).
Data as JSON: /api/errors/26a53c6a6ae7e951.
Report an issue: GitHub.
Appendix: source
Thrown at server/src/services/asset.service.ts:80
const stats = await this.assetRepository.getStatistics(auth.user.id, dto);
return mapStats(stats);
}
async get(auth: AuthDto, id: string): Promise<AssetResponseDto | SanitizedAssetResponseDto> {
await this.requireAccess({ auth, permission: Permission.AssetRead, ids: [id] });
const asset = await this.assetRepository.getById(id, {
exifInfo: true,
owner: true,
faces: { person: true, viewingUserId: auth.user.id },
stack: { assets: true },
edits: true,
tags: true,
});
if (!asset) {
throw new BadRequestException('Asset not found');
}
if (auth.sharedLink && !auth.sharedLink.showExif) {
return mapAsset(asset, { stripMetadata: true, withStack: true, auth });
}
const data = mapAsset(asset, { withStack: true, auth });
if (auth.sharedLink) {
delete data.owner;
}
if (auth.sharedLink) {
data.people = [];
}
return data;
}View on GitHub (pinned to e55ac299a4)