fix(scripts): say what drifted when the notices check fails - #3154
Conversation
📝 WalkthroughSummaryThis PR improves
Design and scopeThe change extends the existing notice-generation and comparison path. It does not create a parallel source of truth or add dependencies. The implementation is a small, focused change. The added No public or exported declarations changed. No code or tests are identified for deletion or simplification without reducing diagnostic coverage. Risks and validationThe main behavior change affects check-mode error output. It does not change notice generation or dependency resolution. Validation used The final status of required checks is unverified from the available evidence. Review-relevant risksNo protected-area effect was identified in the current diff. The person performing the merge must review the final diff, and a maintainer makes the final determination. WalkthroughThe notice generator now explains stale third-party notice files. Check mode separately reports missing files and content drift, including package differences or the first differing line. ChangesThird-party notice validation
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: 🔵 Low · up to On CRLF-formatted notice files, the new check can misclassify unchanged packages and report misleading closure drift instead of the actual text difference. The fix is localized and does not affect notice generation, so the PR is mergeable with explicit owner follow-up to normalize line endings. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
Improves the developer/CI experience for npm run check:third-party-notices by enriching failure diagnostics so mismatches in the generated third-party notices file explain what drifted (dependency closure vs notice text), rather than reporting a generic “stale” error.
Changes:
- Adds a drift-description helper that reports missing/extra packages (capped list) or the first differing line when the package set is unchanged.
- Splits “missing output file” into a dedicated error message with an appropriate remediation.
- Keeps the underlying byte-for-byte comparison behavior unchanged while improving the error output.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: c274ba61-3f1b-40ad-82ca-14d349976554
📒 Files selected for processing (1)
scripts/generate-third-party-notices.mjs
Included review availability: Your plan includes up to 3 reviews per rolling hour; 1 remains after this review.
|
Both bots landed on the same defect and both were right — fixed in I reproduced it before changing anything: Every package reported as both added and removed, which also means the text-drift branch never runs. So under CRLF the diagnostic would have misdescribed exactly the environment-specific failure it exists to explain — the worst possible case for this particular tool. Both sides now split on either ending and trim the extracted name. While there I added a third outcome. If every line matches once endings are normalized, the difference is the endings, and saying "regenerate" is wrong — the repository already forces LF through All three paths exercised against the real file: a deleted package section reports Note this PR's |
`--check` compares 15k generated lines byte-for-byte and reports only that they are stale. Whoever hits it is usually reading a CI log for an OS they are not holding, and the suggested command is the fix for only one of the two causes. The check now separates them. A changed dependency closure names the packages on each side, capped at ten with a count. Identical packages whose notice text moved say so and point at the first differing line with both versions quoted — that shape is not a missed regeneration and the suggested command will not explain it. Found while diagnosing a failure this reports in one line: the same packages listed, first difference at line 430, which localizes it to LICENSE content rather than a dependency change. Claude-Session: https://claude.ai/code/session_014ajaRxC4jydavY9nYUFj5J
`packagesIn` split on `\n` only, so a CRLF checkout left `\r` on every extracted name. The same package set then reported as both added and removed, and the text-drift branch — the useful half — never ran. The diagnostic would have misdescribed precisely the environment-specific failure it exists to explain. Both sides now split on either ending and the extracted names are trimmed. While there: when every line matches after normalizing, the difference is the endings themselves. That now says so, and points at .gitattributes and the checkout instead of at the dependency closure, because regenerating cannot fix it and this repository already forces LF. Claude-Session: https://claude.ai/code/session_014ajaRxC4jydavY9nYUFj5J
315b8f6 to
1c14c53
Compare
|
Fast-path determination on head 1c14c53: this is a low-impact, easy-to-revert diagnostics-only change. It does not alter notice generation, dependency resolution, or the byte-exact comparison; it only explains a failing check. CRLF handling is present, the AI-use disclosure is now explicit, and every required hosted check is terminal green on this head. I reviewed the final diff and found no blocking correctness issue. |
Problem
npm run check:third-party-noticescompares a 15k-line generated file byte-for-byte and, on a mismatch, says only:Two different causes produce that message, and the suggested command only fixes one of them:
Whoever hits this is usually reading a CI log for an OS they are not sitting in front of, so there is nothing to act on but a guess.
Change
The check now names the drift.
Changed closure — packages on each side, capped at ten with a count:
Same packages, different text — the first differing line, both versions quoted:
A missing output file also gets its own message instead of sharing the stale one, since "run the generator" is the whole answer there.
No dependencies added; the comparison itself is unchanged.
How I know it works
Both branches were exercised against the real file: deleting one package's section produced the first output above, and the second is the actual current output on
main.That second one is not hypothetical. It localized a real failure in one line — same packages, line 430 — which pointed at
LICENSEcontent rather than a dependency change, and from there to #3140 having landed without the notices file being regenerated. The Windowspackagejob that runs this check does not listLICENSEin its trigger paths, so that PR never ran it. I will send the regeneration separately, since it is a different concern from the diagnostics.Verified with
npm cirather than an incremental install, so the closure matches what CI resolves.AI use
Tool and scope: Claude Code assisted with the implementation and diagnostics. The human contributor reviewed the work and accepts responsibility for the contribution.
Checklist
Does this PR entail a change in behavior?