[ISSUE 6334] : Add uri validation for regex and other operators.#6335
Open
hengyuss wants to merge 2 commits intoapache:masterfrom
Open
[ISSUE 6334] : Add uri validation for regex and other operators.#6335hengyuss wants to merge 2 commits intoapache:masterfrom
hengyuss wants to merge 2 commits intoapache:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #6334 by extending ShenYu Admin’s URI condition validation during rule creation/update so that invalid URI patterns (not just pathPattern) are rejected before being persisted and synced to the Gateway, preventing runtime failures (e.g., PatternSyntaxException) during route matching.
Changes:
- Introduces a new
UriConditionValidatorutility to validate URI condition values per operator (e.g.,pathPattern,regex,=,startsWith,endsWith). - Updates
RuleService#createOrUpdateto validate allParamType=uriconditions via the new validator. - Minor javadoc alignment adjustments in
RuleService.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| shenyu-admin/src/main/java/org/apache/shenyu/admin/validation/validator/UriConditionValidator.java | Adds centralized operator-based validation logic for URI rule conditions. |
| shenyu-admin/src/main/java/org/apache/shenyu/admin/service/RuleService.java | Applies the new URI condition validation during rule create/update. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Fixes #6334
Currently, when creating or updating a Rule in ShenYu Admin, the URI condition validation only checks the
PATH_PATTERNoperator.If a user selects other operators like
regex,=,startsWith, orendsWithand inputs an invalid format (e.g., an unclosed regex like[a-z+), the Admin console skips the validation and successfully saves the dirty data to the database.When this dirty data is synced to the Gateway, it causes severe runtime exceptions (e.g.,
PatternSyntaxException) during route matching, potentially crashing the routing process.I create a new class UriConditionValidator to modify or add condition
Make sure that:
./mvnw clean install -Dmaven.javadoc.skip=true.