Skip to content

GET /api/assets ignores the hash query parameter #17452

Open

Description

@jaeone94

Summary

GET /api/assets ignores a hash query parameter. ListAssetsQuery in app/assets/api/schemas_in.py has no hash field, and the model is configured with extra="ignore", so the parameter is silently dropped. /api/assets?hash=<value>&limit=1 therefore returns the newest asset rather than an empty list when nothing has that hash.

Impact on the frontend

The frontend resolves a widget value to its asset with GET /api/assets?hash=<filename>&limit=1&include_public=true when the value is not already in the loaded asset lists. Comfy Cloud filters by hash, so an empty result means "absent". Against core with --enable-assets:

  • The missing-media scan can treat an absent file as present, because the lookup always returns some row.
  • The HDR preview lookup in Load Image can attach the newest asset's preview_id to an unrelated value.

Expected

One of:

  • Support hash as an exact-match filter on GET /api/assets, matching Cloud. This is preferred.
  • Reject unknown query parameters with 400, so callers can tell the filter was not applied.

Repro

  1. Start core with --enable-assets and generate a couple of images.
  2. curl '<host>/api/assets?hash=does-not-exist.png&limit=1'
  3. Observed: one asset (the newest). Expected: {"assets": [], ...}.

Context

Found while reviewing Comfy-Org/ComfyUI_frontend#22330 (Load Image HDR previews, part of Comfy-Org/ComfyUI_frontend#22196).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions