Skip to content

fix: say which strings an absolutePath keyword accepts - #223

Merged
alexander-akait merged 1 commit into
mainfrom
claude/filter-errors-quadratic-sibling-dos-1tqe2l
Sep 8, 2026
Merged

fix: say which strings an absolutePath keyword accepts#223
alexander-akait merged 1 commit into
mainfrom
claude/filter-errors-quadratic-sibling-dos-1tqe2l

Conversation

@alexander-akait

Copy link
Copy Markdown
Member

Fixes #66.

Summary

Two things made a relative path given to a rule condition hard to read. Both are visible in the report on the issue.

The type list described a string carrying the absolutePath keyword as a plain string, so it offered string for "node_modules" — a string, and rejected. stringHints already qualifies a string type this way (minLength: 1 reads non-empty string), so the keyword now feeds the same mechanism:

- RegExp | string | function
+ RegExp | absolute path string | function

absolutePath: false reads relative path string, which is how output.filename now describes itself — matching what its own schema description already said ("You must not specify an absolute path here!").

Separately, a failure a schema reaches through more than one branch was listed once per branch. exclude is a oneOf whose branches both reach "array of conditions", so exclude: ["node_modules"] produced two identical details, which kept the single-child fast path from collapsing them and printed the whole rule type instead:

 - configuration.module.rules[0] should be one of these:
   ["..." | false | 0 | "" | null | undefined | object { assert?, compiler?, … 30 keys … }, ...]
   -> A rule.
   Details:
    * configuration.module.rules[0].exclude[0]: The provided value "node_modules" is not an absolute path!
    * configuration.module.rules[0].exclude[0]: The provided value "node_modules" is not an absolute path!

Children formatting to a message an earlier one produced are dropped, which leaves:

 - configuration.module.rules[0].exclude[0]: The provided value "node_modules" is not an absolute path!

What kind of change does this PR introduce?

A fix.

Did you add tests for your changes?

Yes, the case asked for on the issue - both spellings from the report driven against webpack's own schema, asserting the whole message rather than a fragment, plus one holding the type list to absolute path string.

Four snapshots move and each one improves: the duplicate detail line disappears, two output.filename reports gain relative path string, and an array of absolute paths reads [integer, absolute path string, ...]. A fifth is an incidental grammar fix - getArticle covers the string case now, so empty string no longer reads as "a empty string".

Does this PR introduce a breaking change?

No. The errors array is untouched; only the rendered message changes. absolutePath is declared on ExtendedSchema, where the other keywords of this package already live.

If relevant, what needs to be documented once your changes are merged or what have you already documented?

n/a

Note on the earlier attempt in #68: it proposed moving absolutePath from addKeyword to addFormat and adding a humanize helper. Neither is needed to get this reading, and the move would break consumers whose schemas use the keyword, so this takes the smaller path through stringHints.

🤖 Generated with Claude Code

https://claude.ai/code/session_013wqLmVHkAGBsWQgXknEQCK


Generated by Claude Code

A string carrying the keyword was described as a plain `string`, so the list
of accepted types offered `string` for a value like `"node_modules"` that is
a string and is rejected. It reads `absolute path string` now, or `relative
path string` for the `false` form - `output.filename` says so where its own
description already did.

The same report listed a failure once per branch that reached it: a rule
condition is reachable both directly and through the array of conditions, so
`exclude: ["node_modules"]` printed the whole rule type and the same detail
twice. Children formatting to a message an earlier one produced are dropped,
which leaves the single line naming the path.

`getArticle` covers the string case as well now, so `empty string` no longer
reads as `a empty string`.

Fixes #66

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013wqLmVHkAGBsWQgXknEQCK
@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.96%. Comparing base (5c21244) to head (92bca62).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #223      +/-   ##
==========================================
+ Coverage   95.78%   95.96%   +0.18%     
==========================================
  Files           9        9              
  Lines         949      967      +18     
  Branches      387      392       +5     
==========================================
+ Hits          909      928      +19     
+ Misses         36       35       -1     
  Partials        4        4              
Flag Coverage Δ
integration 95.96% <100.00%> (+0.18%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@alexander-akait
alexander-akait merged commit 49bb7ce into main Sep 8, 2026
33 checks passed
@alexander-akait
alexander-akait deleted the claude/filter-errors-quadratic-sibling-dos-1tqe2l branch September 8, 2026 13:56
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.

misleading error message: configuration.module.rules[].exclude

1 participant