From efefbe17da734171b5fec2a2fe32278619590288 Mon Sep 17 00:00:00 2001 From: Michael Uloth Date: Thu, 21 May 2026 05:15:10 +0000 Subject: [PATCH 1/2] docs: fix stale codebase example in README.invariant.md #28 The "Good: Post-Validation Assertion" example cited lib/cloudinary/fetchCloudinaryImageMetadata.ts with a dimensions invariant that no longer exists. The file moved to io/cloudinary/ and the dimensions check was removed. Replace the stale example with the actual invariant present in that file: the publicId non-empty guard in generateResponsiveImageUrls. Update the section heading to "Pre-Condition Guard" to accurately describe the replacement. Also update the path in the "Bad" example from lib/cloudinary/ to io/cloudinary/ and clarify the parenthetical. Closes #28 https://claude.ai/code/session_01NX6Sqy1LRifn2ZbMjm4gcM --- utils/errors/README.invariant.md | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/utils/errors/README.invariant.md b/utils/errors/README.invariant.md index e467441..3209d03 100644 --- a/utils/errors/README.invariant.md +++ b/utils/errors/README.invariant.md @@ -181,16 +181,12 @@ function getPost(slug: string) { ## Examples from Codebase -### Good: Post-Validation Assertion +### Good: Pre-Condition Guard ```typescript -// lib/cloudinary/fetchCloudinaryImageMetadata.ts -// Zod has already validated width/height are numbers -invariant(metadata.width > 0 && metadata.height > 0, 'Image dimensions must be positive', { - width: metadata.width, - height: metadata.height, - publicId, -}) +// io/cloudinary/fetchCloudinaryImageMetadata.ts +// publicId has already been parsed from a validated Cloudinary URL +invariant(publicId.trim().length > 0, 'generateResponsiveImageUrls: publicId must not be empty') ``` ### Good: Documenting Complete Mapping @@ -205,7 +201,7 @@ invariant(ariaLabel, 'Emoji must have aria-label', { symbol }) ### Bad: Checking Function That Throws ```typescript -// lib/cloudinary/fetchCloudinaryImageMetadata.ts (old code) +// io/cloudinary/fetchCloudinaryImageMetadata.ts (old code, before this pattern was removed) const publicId = parsePublicIdFromCloudinaryUrl(url) invariant(publicId, 'Parser must find publicId') // BAD: parsePublicIdFromCloudinaryUrl throws if it can't parse From b1bf2191955605468790f8be052377c2e34689ad Mon Sep 17 00:00:00 2001 From: Michael Uloth Date: Mon, 15 Jun 2026 19:12:00 -0400 Subject: [PATCH 2/2] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- utils/errors/README.invariant.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/errors/README.invariant.md b/utils/errors/README.invariant.md index 3209d03..94e387b 100644 --- a/utils/errors/README.invariant.md +++ b/utils/errors/README.invariant.md @@ -185,7 +185,7 @@ function getPost(slug: string) { ```typescript // io/cloudinary/fetchCloudinaryImageMetadata.ts -// publicId has already been parsed from a validated Cloudinary URL +// publicId is expected to be a non-empty Cloudinary public ID string invariant(publicId.trim().length > 0, 'generateResponsiveImageUrls: publicId must not be empty') ```