Skip to content

CloudinaryResourceSchema accepts empty-string public_id — downstream assertion fires with no useful context #97

@ooloth

Description

@ooloth

Why

CloudinaryResourceSchema validates public_id as z.string() with no minimum length, so an empty string passes schema validation and only fails later when generateResponsiveImageUrls asserts publicId.trim().length > 0 — at which point all context about which API response contained the empty value is gone.

Current state

io/cloudinary/fetchCloudinaryImageMetadata.ts lines 52–56: CloudinaryResourceSchema = z.object({ public_id: z.string(), ... }). The public_id field accepts any string including empty. generateResponsiveImageUrls asserts non-empty further downstream, but at that point the connection to the originating API response is lost and the error message cannot name the offending resource.

Ideal state

  • CloudinaryResourceSchema uses z.string().min(1) for public_id.
  • An empty public_id from the API is caught and reported as a schema validation failure with context about the specific resource, before the value reaches any downstream assertion.

Starting points

  • io/cloudinary/fetchCloudinaryImageMetadata.ts — lines 52–56, the CloudinaryResourceSchema definition

QA plan

  1. Pass a Cloudinary API response with public_id: "" through CloudinaryResourceSchema.safeParse — expect a Zod validation error naming the public_id field.
  2. Pass a response with a valid public_id — expect parsing succeeds as before.

Done when

CloudinaryResourceSchema rejects empty-string public_id values at the API boundary with a descriptive Zod error.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions