immich-app/immich · warning
Unexpected path type:
Error message
Unexpected path type:
What it means
savePath's switch has no matching case for the given path type (only UserPathType.Profile is shown warning here); the function logs 'Unexpected path type:' with the value and returns without saving. In practice this means the new path was moved on disk but never persisted in the database.
Solutions
- Add a case for the new path type in savePath's switch
- Verify which pathType value is being logged and pass the correct enum
- Update code after enum changes instead of reusing stale call sites
- Fail loudly instead of warn-return when the path type is unknown
Example fix
// before
case UserPathType.Profile:
this.logger.warn('Unexpected path type:', pathType);
return;
// after
default:
throw new Error(`Unexpected path type: ${pathType}`); Defensive patterns
Strategy: validation
Validate before calling
const handled = [AssetPathType.Original, AssetPathType.JPEG, AssetPathType.Preview, AssetPathType.EncodedVideo, PersonPathType.Face, UserPathType.Profile];
if (!handled.includes(pathType)) throw new Error(`Unhandled path type: ${pathType}`); Type guard
function isKnownPathType(v: string): v is AssetPathType | PersonPathType | UserPathType { return handled.includes(v as never); } Try / catch
try {
await moveFile(pathType, id, newPath);
} catch (e) {
if (String(e).includes('Unexpected path type')) revertFilesystemMove(newPath, oldPath);
throw e;
} Prevention
- Make the switch exhaustive with a default that throws
- Run a compiler check (TS exhaustive switch) after enum changes
- Add tests covering every path-type enum value
- Never warn-and-return after the file was already moved on disk
When it happens
Trigger: moveFile -> savePath receives a pathType not handled by the switch — e.g. an enum value added later or a type passed incorrectly — landing in a fall-through case that logs the warning.
Common situations: Upgrading Immich and running a migration that passes a new AssetPathType/PersonPathType value the running savePath does not know; calling moveFile with AssetPathType vs PersonPathType confusion; developer-added enum member without a case.
Related errors
- The database currently has
- Unable to save person path without an owner
- Unsupported vector extension
- Admin account does not exist
- Album must have an owner
AI-assisted analysis of immich-app/immich@e55ac299a4 (2026-09-15).
Data as JSON: /api/errors/af99dc5a0ea2695a.
Report an issue: GitHub.
Appendix: source
Thrown at server/src/cores/storage.core.ts:350
case AssetFileType.EncodedVideo:
case AssetFileType.Thumbnail:
case AssetFileType.Preview:
case AssetFileType.Sidecar:
case AssetPathType.EncodedVideo: {
return this.assetRepository.upsertFile({ assetId: id, type: pathType as AssetFileType, path: newPath });
}
case PersonPathType.Face: {
if (!ownerId) {
this.logger.warn('Unable to save person path without an owner');
return;
}
return this.personRepository.update({ ownerId, personGroupId: id, thumbnailPath: newPath });
}
case UserPathType.Profile: {
this.logger.warn('Unexpected path type:', pathType);
return;
}
}
}
static getNestedFolder(folder: StorageFolder, ownerId: string, filename: string): string {
return join(StorageCore.getFolderLocation(folder, ownerId), filename.slice(0, 2), filename.slice(2, 4));
}
static getNestedPath(folder: StorageFolder, ownerId: string, filename: string): string {
return join(StorageCore.getNestedFolder(folder, ownerId, filename), filename);
}
private async getDevices() {
try {
return await this.storageRepository.readdir('/dev/dri');
} catch {
this.logger.debug('No devices found in /dev/dri.');View on GitHub (pinned to e55ac299a4)