Repository navigation
fix(config): correctly validate cacheHandlers names - #95358
Merged
unstubbable merged 1 commit intoJul 2, 2026
Merged
Conversation
unstubbable
force-pushed
the
fix-cachehandlers-validation
branch
from
July 2, 2026 13:55
e512a66 to
78277a4
Compare
Contributor
Stats cancelledCommit: 78277a4 |
Contributor
Tests PassedCommit: 78277a4 |
m-kawafuji
pushed a commit
to m-kawafuji/next.js
that referenced
this pull request
Aug 8, 2026
## What? The current `cacheHandlers` validation uses `/[a-z-]/`, which only checks whether a key contains at least one lowercase letter or hyphen. As a result, invalid keys such as `abc123`, `abc_123`, `abc.def`, and `handler!` are accepted even though they contain characters outside the documented allowed set. ## Why? The validation error states that handler names must only contain `a-z` and `-`, but the current implementation does not enforce that constraint because the regex is not anchored. ## How? - Replace `/[a-z-]/` with `/^[a-z-]+$/` so the entire handler name is validated. - Add regression tests covering both valid and invalid handler names. ## Testing - Added regression tests in `packages/next/src/server/config.test.ts`. <!-- NEXT_JS_LLM_PR -->
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.
What?
The current
cacheHandlersvalidation uses/[a-z-]/, which only checks whether a key contains at least one lowercase letter or hyphen.As a result, invalid keys such as
abc123,abc_123,abc.def, andhandler!are accepted even though they contain characters outside the documented allowed set.Why?
The validation error states that handler names must only contain
a-zand-, but the current implementation does not enforce that constraint because the regex is not anchored.How?
/[a-z-]/with/^[a-z-]+$/so the entire handler name is validated.Testing
packages/next/src/server/config.test.ts.