Skip to content

Fix stale codebase example in README.invariant.md "Post-Validation Assertion" section #28

Description

@ooloth

Why

The "Good: Post-Validation Assertion" example cites a file path and an invariant call that no longer exist, so a reader following the example to the source will find neither the path nor the assertion.

Current state

utils/errors/README.invariant.md lines 187–194 show:

// 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,
})

The file has moved to io/cloudinary/fetchCloudinaryImageMetadata.ts and no longer contains a dimensions invariant. The actual file validates and builds the metadata object directly from parseResult.data, then constructs CloudinaryImageMetadata without asserting positive dimensions at runtime.

Ideal state

  • The example either references the current file path (io/cloudinary/fetchCloudinaryImageMetadata.ts) with a call that actually exists there, or is replaced with a different example drawn from code that is present in the codebase.
  • A reader can open the cited file and find the illustrative code.

Starting points

  • utils/errors/README.invariant.md — lines 184–194, the "Good: Post-Validation Assertion" block
  • io/cloudinary/fetchCloudinaryImageMetadata.ts — the actual current file (no dimensions invariant present)

QA plan

  1. Open utils/errors/README.invariant.md and read the "Good: Post-Validation Assertion" example — expect the file path and invariant call to match code that exists in the repository.
  2. Open the cited file — expect to find the exact invariant call shown in the example.

Done when

The example in README.invariant.md references a file path and invariant call that a reader can locate in the current codebase.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions