immich-app/immich · warning · BadRequestException

May not request original file

Error message

May not request original file

What it means

Thrown by AssetMediaService.viewThumbnail when dto.size === AssetMediaSize.Original. The thumbnail endpoint exists to serve downscaled previews/full-size renditions, never the source file; requesting the original here is explicitly rejected. The original must be fetched via the dedicated original endpoint (the DTO itself notes 'original' is deprecated for this route).

Source

Thrown at server/src/services/asset-media.service.ts:259

    const path = editedPath ?? originalPath!;

    return new ImmichFileResponse({
      path,
      fileName: getFileNameWithoutExtension(originalFileName) + getFilenameExtension(path),
      contentType: mimeTypes.lookup(path),
      cacheControl: CacheControl.PrivateWithCache,
    });
  }

  async viewThumbnail(
    auth: AuthDto,
    id: string,
    dto: AssetMediaOptionsDto,
  ): Promise<ImmichFileResponse | AssetMediaRedirectResponse> {
    await this.requireAccess({ auth, permission: Permission.AssetView, ids: [id] });

    if (dto.size === AssetMediaSize.Original) {
      throw new BadRequestException('May not request original file');
    }

    if (auth.sharedLink) {
      dto.edited = true;
    }

    const size = (dto.size ?? AssetMediaSize.THUMBNAIL) as unknown as AssetFileType;
    const { originalPath, originalFileName, path } = await this.assetRepository.getForThumbnail(
      id,
      size,
      dto.edited ?? false,
    );

    if (size === AssetFileType.FullSize && mimeTypes.isWebSupportedImage(originalPath) && !dto.edited) {
      // use original file for web supported images
      return { targetSize: 'original' };
    }

View on GitHub (pinned to 199723261c)

Solutions

  1. Use the original endpoint (GET /assets/:id/original) to fetch the source file
  2. Request a valid thumbnail size (preview, fullsize, thumbnail) on this endpoint
  3. Upgrade the client SDK to a version that targets the correct endpoint

Example fix

// before
await sdk.viewThumbnail(id, { size: 'original' }); // 400
// after
await sdk.getOriginalAsset(id); // dedicated original endpoint
Defensive patterns

Strategy: validation

Validate before calling

// Route original requests to the dedicated endpoint
const size = requestedSize === 'original' ? null : requestedSize;
if (requestedSize === 'original') {
  return sdk.getOriginalAsset(id);
}
return sdk.viewThumbnail(id, { size });

Type guard

function isValidThumbnailSize(s: string): boolean {
  return ['thumbnail','preview','fullsize'].includes(s);
}

Prevention

When it happens

Trigger: GET /assets/:id/thumbnail?size=original — the client requests the unmodified source through the thumbnail route.

Common situations: Older SDK versions that still send size=original to this endpoint; client code assuming one endpoint fits all sizes; migration from a previous API version that allowed it.

Related errors


AI-assisted analysis of immich-app/immich@199723261c (2026-08-12). Data as JSON: /api/errors/41af444ecec10dd0. Report an issue: GitHub.