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
- Pass a Cloudinary API response with
public_id: "" through CloudinaryResourceSchema.safeParse — expect a Zod validation error naming the public_id field.
- 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.
Why
CloudinaryResourceSchemavalidatespublic_idasz.string()with no minimum length, so an empty string passes schema validation and only fails later whengenerateResponsiveImageUrlsassertspublicId.trim().length > 0— at which point all context about which API response contained the empty value is gone.Current state
io/cloudinary/fetchCloudinaryImageMetadata.tslines 52–56:CloudinaryResourceSchema = z.object({ public_id: z.string(), ... }). Thepublic_idfield accepts any string including empty.generateResponsiveImageUrlsasserts 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
CloudinaryResourceSchemausesz.string().min(1)forpublic_id.public_idfrom 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, theCloudinaryResourceSchemadefinitionQA plan
public_id: ""throughCloudinaryResourceSchema.safeParse— expect a Zod validation error naming thepublic_idfield.public_id— expect parsing succeeds as before.Done when
CloudinaryResourceSchemarejects empty-stringpublic_idvalues at the API boundary with a descriptive Zod error.