fix: detect content drift in generated webiny package during validation - #5476
Merged
Merged
Conversation
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
marked this pull request as draft
August 4, 2026 14:13
|
🚓 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
validate-webiny-packagesaid "The `webiny` package is up to date" even when export code had been added directly into the generatedwebinypackage, instead of following the sourcesrc/exportsfolder convention (e.g.packages/app-admin/src/exports/*.ts).Root cause — the validation only ever checked two things:
packages/*/src/exports/**/*.ts),@webiny/iconssrc, andsrc-static. Nothing from the generatedwebiny/srcoutput feeds the hash, so hand-editing generated files can't move it.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-packagerun 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 areoxfmt-formatted (multi-line, wrapped at print width) whilecomputeGenerationResult()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
webiny/srcadmin.ts (content drift)→ exit 1Known remaining blind spots (not addressed here)
.tsxfiles insrc/exportsare silently skipped (ScanExportsFoldersService.ts.ts-only filter).packages/*are scanned — rootextensions/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/HttpRouteDefinitionexports straight into the generatedpackages/webiny/src/api.ts, becauseevent-handler-corehad nosrc/exports/folder. Validation reported "Thewebinypackage is up to date", it merged, and the nextgenerate-webiny-packagerun wiped the exports — caught only because a human noticed.All three existing checks passed, for exactly the reasons above:
src/exports/**, icons src andsrc-staticfeed it. Editing the output cannot move it.api.tswas expected and present.exportsfield./apialready existed from other packages, so the map was unchanged.Re-verified on this branch after merging
next:The webiny package is up to date.api.ts (content drift), exit 1The real fix in that case was to give
event-handler-coreasrc/exports/api.ts, which is what the convention wants. This check is what makes that mistake fail loudly instead of silently.