{"record":{"id":"7721c499362f416c","repo":"apache/shenyu","slug":"uri-validation-of-condition-failed-please-check","errorCode":null,"errorMessage":"uri validation of Condition failed, please check.","messagePattern":"uri validation of Condition failed, please check\\.","errorType":"validation","errorClass":"ShenyuAdminException","httpStatus":null,"severity":"error","filePath":"shenyu-admin/src/main/java/org/apache/shenyu/admin/service/RuleService.java","lineNumber":65,"sourceCode":"     */\n    String registerDefault(RuleDTO ruleDTO);\n\n    /**\n     * create or update rule.\n     *\n     * @param ruleDTO {@linkplain RuleDTO}\n     * @return rows int\n     */\n    default int createOrUpdate(final RuleDTO ruleDTO) {\n        try {\n            final List<RuleConditionDTO> ruleConditions = ruleDTO.getRuleConditions();\n            ruleConditions.stream()\n                    .filter(conditionData -> ParamTypeEnum.URI.getName().equals(conditionData.getParamType()))\n                    .forEach(conditionData -> {\n                        UriConditionValidator.validate(conditionData.getOperator(), conditionData.getParamValue());\n                    });\n        } catch (Exception e) {\n            throw new ShenyuAdminException(\"uri validation of Condition failed, please check.\", e);\n        }\n        return StringUtils.isBlank(ruleDTO.getId()) ? create(ruleDTO) : update(ruleDTO);\n    }\n\n    /**\n     * create rule.\n     *\n     * @param ruleDTO {@linkplain RuleDTO}\n     * @return rows int\n     */\n    int create(RuleDTO ruleDTO);\n\n    /**\n     * update rule.\n     *\n     * @param ruleDTO {@linkplain RuleDTO}\n     * @return rows int\n     */","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/RuleService.java#L47-L83","documentation":"RuleService.createOrUpdate validates rule conditions before persisting: for every condition whose paramType is 'uri', UriConditionValidator.checks the operator/paramValue combination (uri regex/validity). Any validation exception is wrapped in ShenyuAdminException(\"uri validation of Condition failed, please check.\") and the rule is not created or updated. The wrapped cause names the exact operator/value problem.","triggerScenarios":"Saving a rule via the admin API/dashboard with a URI condition whose paramValue is not valid for the chosen operator — e.g. an invalid regex for the 'regex' operator, malformed path pattern, or illegal characters for '='/'match' operators.","commonSituations":"Dashboard users typing hand-crafted regex with unbalanced brackets or invalid escapes; automation scripts posting rule JSON with empty uri paramValue; copy-pasted patterns containing whitespace or unencoded characters; version differences in what operators accept.","solutions":["Look at the wrapped cause in the log — UriConditionValidator says which condition's operator/value is invalid.","Fix the rule condition paramValue: for the regex operator supply a valid Java regex (e.g. /foo/**, no unbalanced brackets).","Ensure the operator matches the paramType 'uri' (one of =, match, regex, etc.) and paramValue is non-empty.","Test the pattern locally with Pattern.compile() before submitting it through the dashboard/API."],"exampleFix":"// before (invalid regex)\n{ \"paramType\": \"uri\", \"operator\": \"regex\", \"paramValue\": \"/foo/**(\" }\n// after\n{ \"paramType\": \"uri\", \"operator\": \"regex\", \"paramValue\": \"/foo/**\" }","handlingStrategy":"validation","validationCode":"// client-side pre-check for uri regex conditions\ntry {\n    java.util.regex.Pattern.compile(conditionData.getParamValue());\n} catch (java.util.regex.PatternSyntaxException e) {\n    throw new IllegalArgumentException(\"invalid uri regex: \" + conditionData.getParamValue());\n}","typeGuard":null,"tryCatchPattern":"try {\n    ruleService.createOrUpdate(ruleDTO);\n} catch (ShenyuAdminException e) {\n    if (e.getMessage().contains(\"uri validation\"))\n        LOG.warn(\"reject rule {}: invalid uri condition (see cause)\", ruleDTO.getId(), e.getCause());\n}","preventionTips":["Test regex patterns with Pattern.compile before submitting","Keep paramValue non-empty and percent-encode special characters","Only use operators supported for the 'uri' paramType","Validate rule payloads in CI scripts that automate rule creation"],"tags":["rule-validation","uri-condition","regex","admin-api"],"backgroundTag":"schema-validation-failed","analyzedSha":"567142e07261b3e615ae8850b30f4421f455cc5d","analyzedAt":"2026-09-12T10:08:21.293Z","contentChangedAt":"2026-09-12T10:08:21.293Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}