Skip to content

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

Merged
adrians5j merged 3 commits into
nextfrom
fix/validate-webiny-pkg-content-drift
Sep 10, 2026
Merged

adrians5j merged 3 commits into
nextfrom
fix/validate-webiny-pkg-content-drift

Conversation

@adrians5j

@adrians5j adrians5j commented Jul 22, 2026 •

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


Confirmed against a real occurrence (2026-09-10)

This is no longer hypothetical. In #5673 I hand-wrote HttpRouteHandler / HttpRouteDefinition exports straight into the generated packages/webiny/src/api.ts, because event-handler-core had no src/exports/ folder. Validation reported "The webiny package is up to date", it merged, and the next generate-webiny-package run wiped the exports — caught only because a human noticed.

All three existing checks passed, for exactly the reasons above:

Check Why it passed
Inputs hash Only source src/exports/**, icons src and src-static feed it. Editing the output cannot move it.
File paths api.ts was expected and present.
exports field ./api already existed from other packages, so the map was unchanged.

Re-verified on this branch after merging next:

  • clean repo → The webiny package is up to date.
  • the same hand-edit re-applied → api.ts (content drift), exit 1

The real fix in that case was to give event-handler-core a src/exports/api.ts, which is what the convention wants. This check is what makes that mistake fail loudly instead of silently.

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
@github-actions

Copy link
Copy Markdown

🚓 Slop Cop

✅ Nothing worth flagging. The diff looks consistent with the PR's stated intent and the code-style rules.

Automated, non-blocking heads-up from an LLM. It can be wrong — use your judgment. Regenerates on every push.

@adrians5j adrians5j added the evh-cleanups event-handler DI/transport-agnostic cleanups label Sep 10, 2026
@adrians5j
adrians5j marked this pull request as ready for review September 10, 2026 14:13
@adrians5j
adrians5j merged commit a219f4e into next Sep 10, 2026
121 checks passed
@adrians5j
adrians5j deleted the fix/validate-webiny-pkg-content-drift branch September 10, 2026 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

evh-cleanups event-handler DI/transport-agnostic cleanups

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant