Skip to content

fix(generate): refuse an unstampable package manifest before generating - #1174

Merged
antoinetoussaint-byte merged 1 commit into
mainfrom
fix/client-version-precheck
Oct 26, 2026
Merged

antoinetoussaint-byte merged 1 commit into
mainfrom
fix/client-version-precheck

Conversation

@antoinetoussaint-byte

Copy link
Copy Markdown
Contributor

Follow-up to #1164: the minor finding from review r97.

What was wrong

The version stamp runs after each staged language is applied (#1169's staging). If a package.json has no top-level "version" member, or a pyproject.toml has no version = "…" line, the refusal came after that language had already been rewritten while library.codefly.yaml had not. The library was left half-updated.

Fix

  • Before anything is staged, GenerateClientLibrary checks every requested language's existing manifest with checkPackageVersionStampable. A manifest that doesn't exist yet comes from the scaffold, which declares a version.
  • The check and the stamp share one locator, locatePackageVersion: the JSON token walk for the top-level member in package.json, the version line in pyproject.toml. So the two can't disagree. stampPackageVersion now locates, then writes, and the separate regex replacer is gone.

Tests

  • TestAnUnstampableManifestLeavesTheLibraryUntouched (ungated): a library holding a package.json without a version and a hand-written src/notes.ts. GenerateClientLibrary is refused with cannot find a version, in milliseconds and with no companion run, and a byte-for-byte snapshot of the output tree is unchanged.
  • TestCheckPackageVersionStampable: a missing manifest passes, the scaffold passes, a pyproject.toml with dynamic = ["version"] is refused, and Go is a no-op.
  • go vet, go test -race ./pkg/generators ./cmd/generate and golangci-lint (0 issues) pass. The gated TestGenerateClientPreservesHandEditedFiles passes.

Classification

Fix, at the place that owns the stamp.

🤖 Generated with Claude Code

Review r97 on #1164: the version stamp ran after each language was
applied, so a package.json without a top-level "version" (or a
pyproject.toml without a version line) was refused with the language
already rewritten and library.codefly.yaml not. Every requested
language's existing manifest is now checked before anything is staged,
with the same locator the stamp uses, so the refusal leaves the library
exactly as it was. A manifest not written yet comes from the scaffold,
which declares a version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@antoinetoussaint-byte
antoinetoussaint-byte added this pull request to the merge queue Oct 26, 2026
Merged via the queue into main with commit e3d1390 Oct 26, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant