{"record":{"id":"d746b3dccf0ea44f","repo":"apache/shenyu","slug":"the-uri-condition-value-cannot-be-empty","errorCode":null,"errorMessage":"The URI condition value cannot be empty.","messagePattern":"The URI condition value cannot be empty\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"shenyu-admin/src/main/java/org/apache/shenyu/admin/validation/validator/UriConditionValidator.java","lineNumber":63,"sourceCode":"            if (StringUtils.isNotBlank(value)) {\n                throw new IllegalArgumentException(\"The URI must be blank\");\n            }\n        };\n        VALIDATOR_MAP.put(OperatorEnum.PATH_PATTERN.getAlias(),\n                PathPatternParser.defaultInstance::parse);\n        VALIDATOR_MAP.put(OperatorEnum.REGEX.getAlias(), Pattern::compile);\n        VALIDATOR_MAP.put(OperatorEnum.EQ.getAlias(), commonPathValidator);\n        VALIDATOR_MAP.put(OperatorEnum.STARTS_WITH.getAlias(), commonPathValidator);\n        VALIDATOR_MAP.put(OperatorEnum.ENDS_WITH.getAlias(), commonPathValidator);\n        VALIDATOR_MAP.put(OperatorEnum.MATCH.getAlias(), commonPathValidator);\n        VALIDATOR_MAP.put(OperatorEnum.EXCLUDE.getAlias(), commonPathValidator);\n        VALIDATOR_MAP.put(OperatorEnum.CONTAINS.getAlias(), commonPathValidator);\n        VALIDATOR_MAP.put(OperatorEnum.IS_BLANK.getAlias(), blankPathValidator);\n    }\n\n    public static void validate(final String operator, final String value) {\n        if (!OperatorEnum.IS_BLANK.getAlias().equals(operator) && StringUtils.isBlank(value)) {\n            throw new IllegalArgumentException(\"The URI condition value cannot be empty.\");\n        }\n        Consumer<String> validator = VALIDATOR_MAP.get(operator);\n        if (Objects.nonNull(validator)) {\n            validator.accept(value);\n        }\n    }\n\n}\n","sourceCodeStart":45,"sourceCodeEnd":72,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-admin/src/main/java/org/apache/shenyu/admin/validation/validator/UriConditionValidator.java#L45-L72","documentation":"validate() requires a non-blank value for every URI condition operator except IS_BLANK, whose semantics do not need a value. This guards against operators that would be constructed with empty input (e.g. Pattern.compile(\"\") or a PathPatternParser parse of empty string) and produce silently broken matchers.","triggerScenarios":"Calling UriConditionValidator.validate(operator, value) where operator is anything other than IS_BLANK and value is null, \"\", or whitespace-only — e.g. validate(\"regex\", \"  \").","commonSituations":"Saving a selector rule from the dashboard with the value field left empty, deserialized condition DTOs missing the value field, or programmatic rule generation that skips value population.","solutions":["Provide the URI value for the condition before validating/saving.","If the intent is a blank check, switch the operator to IS_BLANK.","In the dashboard/API client, make the value field required unless the operator is IS_BLANK."],"exampleFix":"// before\nUriConditionValidator.validate(\"regex\", null);\n// after\nUriConditionValidator.validate(\"regex\", \"/api/**\");\n// or for blank checks:\nUriConditionValidator.validate(\"isBlank\", null);","handlingStrategy":"validation","validationCode":"if (!\"isBlank\".equals(operator) && (value == null || value.isBlank())) { throw new IllegalArgumentException(\"Operator \" + operator + \" requires a non-empty URI value\"); }","typeGuard":"boolean requiresValue(String operator, String value) { return \"isBlank\".equals(operator) || (value != null && !value.isBlank()); }","tryCatchPattern":"try { UriConditionValidator.validate(operator, value); } catch (IllegalArgumentException e) { log.error(\"Missing URI condition value for operator {}\", operator); throw e; }","preventionTips":["Make the value field required in the dashboard unless operator is IS_BLANK.","Check DTOs deserialized from API payloads for null/empty value fields.","Write unit tests that exercise each operator with both valid and empty values."],"tags":["validation","uri","empty-value"],"backgroundTag":"empty-required-field","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"}