Skip to content

fix: detect content drift in generated webiny package during validation - #5476

Draft
adrians5j wants to merge 2 commits into
nextfrom
fix/validate-webiny-pkg-content-drift
Draft

fix: detect content drift in generated webiny package during validation#5476
adrians5j wants to merge 2 commits into
nextfrom
fix/validate-webiny-pkg-content-drift

Conversation

@adrians5j

Copy link
Copy Markdown
Member

Problem

validate-webiny-package said "The `webiny` package is up to date" even when export code had been added directly into the generated webiny package, instead of following the source src/exports folder convention (e.g. packages/app-admin/src/exports/*.ts).

Root cause — the validation only ever checked two things:

  1. An inputs hash computed from source export files (packages/*/src/exports/**/*.ts), @webiny/icons src, and src-static. Nothing from the generated webiny/src output feeds the hash, so hand-editing generated files can't move it.
  2. File paths — the deep check asserted expected paths exist and no extra paths are present, but never compared file contents.

So a hand-edit that added exports into an already-expected generated file changed neither the hash nor any path. Validation passed. The next generate-webiny-package run then rebuilt from source and silently wiped those edits.

Fix

Add a content comparison of each expected file against its on-disk counterpart in the deep check.

Comparison is whitespace-normalized (\s+ → single space, trimmed): committed files are oxfmt-formatted (multi-line, wrapped at print width) while computeGenerationResult() returns raw, unformatted merge output. Normalizing absorbs that cosmetic difference while still catching any added / removed / renamed export or changed module path — exactly the hand-edit class that previously slipped through.

Verification

Case Before After
Clean repo up to date ✅ up to date
Export hand-edited into webiny/src up to date (bug) admin.ts (content drift) → exit 1

Known remaining blind spots (not addressed here)

  • .tsx files in src/exports are silently skipped (ScanExportsFoldersService.ts .ts-only filter).
  • Only packages/* are scanned — root extensions/ is never seen.

🤖 Generated with Claude Code

adrians5j and others added 2 commits July 22, 2026 17:57
The `validate-webiny-package` command only compared file paths and an
inputs hash computed from source `src/exports` folders. Hand-edits made
directly inside the generated `webiny` package (e.g. adding exports to an
existing generated file instead of a source package's `src/exports`
folder) changed neither the paths nor the hash, so validation passed —
only for the edits to be silently wiped on the next generation.

Add a whitespace-normalized content comparison of each expected file
against its on-disk counterpart. Normalization absorbs oxfmt line-wrapping
(committed files are formatted; generation output is raw) while still
catching any added, removed, or renamed export and any changed module path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@adrians5j adrians5j added this to the 6.6.0 milestone Aug 2, 2026
@adrians5j
adrians5j marked this pull request as draft August 4, 2026 14:13
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