Fix require-error-code-in-thrown-error false positives on Identifier message args - #51324
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
PR TriageCategory: bug | Risk: low | Score: 38 (impact 15, urgency 8, quality 15) Recommended action: Small, well-scoped ESLint rule fix (47 additions, 2 files). Draft PR, no CI signal yet. Low risk since it only reduces false positives in a custom lint rule and adds tests. Not urgent — safe to defer until undrafted and CI runs.
|
There was a problem hiding this comment.
Pull request overview
Fixes false positives when thrown error messages are stored in local variables.
Changes:
- Resolves write-once initializer chains before checking error codes.
- Leaves unresolvable values unreported.
- Adds regression coverage for resolved and unresolved identifiers.
Show a summary per file
| File | Description |
|---|---|
require-error-code-in-thrown-error.ts |
Adds initializer resolution and static message filtering. |
require-error-code-in-thrown-error.test.ts |
Covers identifier initialization and aliasing cases. |
Review details
Tip
Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Balanced
|
✅ PR Code Quality Reviewer completed the code quality review. Warning Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding. What happenedThe threat detection engine failed to produce results. Review the workflow run logs for details. Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
To allow these domains, add them to the network:
allowed:
- defaults
- "api.individual.githubcopilot.com"See Network Configuration for more information.
|
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. No ADR enforcement needed: PR does not have the 'implementation' label and has 0 new lines of code in business logic directories.
|
|
✅ Test Quality Sentinel completed test quality analysis. No supported test files detected. PR #51324 modifies TypeScript tests (*.test.ts), which are outside the scope of Test Quality Sentinel (analyzes Go *.test.go and JavaScript .test.cjs/.test.js only).
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
There was a problem hiding this comment.
Review Summary
The fix is well-structured: resolving write-once initializer chains eliminates false positives for variables holding template literals built from ERR_* constants, and the fallback-to-silent behaviour for unresolvable values is the right trade-off.
One concern (see inline): the static-value gate on line 80 accepts any BinaryExpression, but only + (string concatenation) is semantically message-like. An arithmetic expression such as const msg = a - b would bypass the lint check. Consider narrowing the guard to operator === '+'.
Otherwise the logic is sound and the test coverage is good.
🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 20.4 AIC · ⌖ 7.17 AIC · ⊞ 5.5K
🧪 Test Quality AnalysisPR: #51324 — "Fix require-error-code-in-thrown-error false positives on Identifier message args" Test ScopeThis PR modifies TypeScript tests in eslint-factory ( Changes Summary
Test/Prod Ratio: 34 test lines : 13 production lines = 2.6:1 (elevated but reasonable for behavioral expansion) New Test Cases3 new
Quality AssessmentStrengths:
Observations:
ConclusionAssessment: Tests provide solid behavioral coverage for the identifier-resolution feature. No violations detected. Note: TypeScript test analysis provided informally. Full Test Quality Sentinel supports Go and JavaScript tests only.
|
There was a problem hiding this comment.
✅ Test Quality Sentinel: Qualitative review of TypeScript tests (outside formal scope). 3 new test cases provide solid behavioral coverage for the write-once initializer resolution feature with good edge-case scenarios and regression protection. No violations detected.
|
@copilot Quick triage nudge for this PR. Please refresh the branch if GitHub can update it cleanly, address the remaining unresolved review feedback below, and run the Open items (newest first):
Branch refresh was requested. Run: https://github.com/github/gh-aw/actions/runs/31248214015
|
Current head |
|
@copilot Quick triage nudge for this PR. Please refresh the branch if GitHub can update it cleanly, review the remaining maintainer-facing follow-up below, and run the Remaining unresolved review threads (newest first):
Run: https://github.com/github/gh-aw/actions/runs/31250442499
|
Current head is still |
|
@copilot Quick triage nudge for this PR. Please refresh the branch if GitHub can update it cleanly, address the remaining unresolved review threads below, and run the Open review threads (newest first):
|
Current head |
|
@copilot Quick triage nudge for this PR. Please refresh the branch if GitHub can update it cleanly, re-confirm whether anything maintainer-facing remains on the current head, and run the Run: https://github.com/github/gh-aw/actions/runs/31255838666
|
Current head is still |
PR Triage (re-affirmed)
Existing labels look correct: eslint rule false-positive fix, CI green (4/4 success), reviewed by automation. No change from prior triage.
|
|
@copilot Quick triage nudge for this PR. Please refresh the branch if GitHub can update it cleanly, review any maintainer-facing follow-up, and run the Run: https://github.com/github/gh-aw/actions/runs/31257633580
|
Current head is still |
|
@copilot Quick triage nudge for this PR. Please refresh the branch if GitHub can update it cleanly, review any maintainer-facing follow-up, and run the
Run: https://github.com/github/gh-aw/actions/runs/31262341296
|
|
🎉 This pull request is included in a new release. Release: |
require-error-code-in-thrown-errortested the identifier's name againstERR_CODE_PATTERNrather than the value it holds, so a message that plainly starts with anERR_*code was reported asmissingErrorCodewhenever it was stored in an ordinary-named variable first. Unlike its sibling interpolation rules, this rule did no scope/initializer resolution at all.Changes
Identifiermessage argument, resolve its write-once local initializer withresolveWriteOnceInitializerChain(the helper already used byno-exec-interpolated-commandandno-github-request-interpolated-route) and evaluatemessageReferencesErrorCodeagainst the resolved expression.Literal,TemplateLiteral, or+BinaryExpression). Parameters, reassigned bindings, and call results (e.g.getErrorMessage(e)re-thrown behind astartsWith(\${ERR_CONFIG}:`)guard inupdate_release.cjs) are left alone — false positives are worse than silence for a"suggestion"`-severity consistency rule.const msg = "no code here"; throw new Error(msg);remains invalid.Against
actions/setup/js, the rule's warning count drops 105 → 97; the three call sites cited in the issue no longer fire, and the remaining warnings in those files are genuinely uncoded messages.Unrelated note:
eslint-factoryhas a pre-existing failure inrequire-fs-io-try-catch.test.ts(5 tests, "Error at index 0 has suggestions") that reproduces on the base commit and is untouched here.Run: https://github.com/github/gh-aw/actions/runs/31248214015> Generated by 👨🍳 PR Sous Chef · gpt54 · 19.2 AIC · ⌖ 6.73 AIC · ⊞ 6.1K · ◷
Run context: https://github.com/github/gh-aw/actions/runs/31250442499> Generated by 👨🍳 PR Sous Chef · gpt54 · 10.2 AIC · ⌖ 5.36 AIC · ⊞ 6.1K · ◷
Run: https://github.com/github/gh-aw/actions/runs/31251975204> Generated by 👨🍳 PR Sous Chef · gpt54 · 16.7 AIC · ⌖ 5.39 AIC · ⊞ 8.5K · ◷
Run: https://github.com/github/gh-aw/actions/runs/31255838666> Generated by 👨🍳 PR Sous Chef · gpt54 · 9.08 AIC · ⌖ 5.36 AIC · ⊞ 8.5K · ◷
Run: https://github.com/github/gh-aw/actions/runs/31257633580> Generated by 👨🍳 PR Sous Chef · gpt54 · 8.32 AIC · ⌖ 5.34 AIC · ⊞ 6.1K · ◷
Run: https://github.com/github/gh-aw/actions/runs/31262341296> Generated by 👨🍳 PR Sous Chef · gpt54 · 10 AIC · ⌖ 5.39 AIC · ⊞ 8.5K · ◷