ITADN

[BUG] Resolve TODO: Add URI validation for other operators in Rule configuration

#6334Openhengyuss 创建于 2026-04-24
type: bug
H
hengyusscommented
### Is there an existing issue for this? - [x] I have searched the existing issues ### Current Behavior ### Description I found a `// todo` comment in the source code regarding the URI validation of `RuleConditionDTO`. Currently, the `createOrUpdate` method in org/apache/shenyu/admin/service/RuleService.java only validates the URI format when the operator is `PATH_PATTERN`, and leaves a TODO for other matching modes: ```java // now, only check rule uri condition in pathPattern mode // todo check uri in other modes ``` I propose to resolve this TODO by implementing strict validations for the remaining operators. My plan is to introduce a UriConditionValidator using the Strategy Pattern to map different operators (regex, =, startsWith, endsWith) to their specific validation logic. This will make the validation robust and keep the main flow clean. I am working on this and will submit a Pull Request shortly. ### Expected Behavior When the URI does not conform to the rules, it should throw an error instead of saving to the database. ### Steps To Reproduce 1. Go to ShenYu Admin Console -> Plugin List -> Add a Rule. 2. Add a condition: ParamType `uri`, Operator `regex`. 3. Input an invalid regex value, for example: `[a-z+` 4. Click Save. 5. **Observe:** The rule is saved successfully without any error prompt. 6. Send a request to the Gateway matching this plugin. 7. **Observe:** Gateway throws `java.util.regex.PatternSyntaxException`. ### Environment ```markdown ShenYu version(s):2.7.1-SNAPSHOT ``` ### Debug logs _No response_ ### Anything else? _No response_
1 条评论