{"record":{"id":"01c99813b3258ceb","repo":"apache/shenyu","slug":"the-uri-must-be-blank","errorCode":null,"errorMessage":"The URI must be blank","messagePattern":"The URI must be blank","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"shenyu-admin/src/main/java/org/apache/shenyu/admin/validation/validator/UriConditionValidator.java","lineNumber":46,"sourceCode":"import java.util.function.Consumer;\n\npublic class UriConditionValidator {\n\n    private static final Map<String, Consumer<String>> VALIDATOR_MAP = new HashMap<>();\n\n    static {\n        Consumer<String> commonPathValidator = value -> {\n            if (!value.startsWith(\"/\")) {\n                throw new IllegalArgumentException(\"The URI must start with '/'\");\n            }\n            if (StringUtils.containsAny(value, \" \", \"\\t\", \"\\n\")) {\n                throw new IllegalArgumentException(\n                        \"The URI cannot contain whitespaces. Current value: \" + value);\n            }\n        };\n        Consumer<String> blankPathValidator = value -> {\n            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        }","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-admin/src/main/java/org/apache/shenyu/admin/validation/validator/UriConditionValidator.java#L28-L64","documentation":"The IS_BLANK operator's validator (blankPathValidator) requires the condition value to be blank/empty — that operator tests for an absent URI. If a non-blank value is supplied together with operator IS_BLANK, validation fails because the value is meaningless for that operator.","triggerScenarios":"Calling UriConditionValidator.validate(\"isBlank\", someValue) (or the OperatorEnum.IS_BLANK alias) with a value that is not null/empty — e.g. validate(\"isBlank\", \"/api\").","commonSituations":"Selecting IS_BLANK in the dashboard but forgetting to clear the value field, or reusing condition-building code that always sets a value regardless of operator.","solutions":["Pass an empty or null value when using the IS_BLANK operator.","Change the operator to one that takes a value (e.g. EQ, PATH_PATTERN) if you actually meant to match a URI.","Clear the value field in the dashboard when switching the operator to IS_BLANK."],"exampleFix":"// before\nUriConditionValidator.validate(\"isBlank\", \"/api/foo\");\n// after\nUriConditionValidator.validate(\"isBlank\", null); // or \"\"","handlingStrategy":"validation","validationCode":"if (\"isBlank\".equals(operator) && value != null && !value.isBlank()) { throw new IllegalArgumentException(\"Operator isBlank requires an empty value\"); }","typeGuard":"boolean isBlankOperatorValueValid(String operator, String value) { return !\"isBlank\".equals(operator) || (value == null || value.isBlank()); }","tryCatchPattern":"try { UriConditionValidator.validate(operator, value); } catch (IllegalArgumentException e) { log.warn(\"Operator/value mismatch: {} {}\", operator, value); }","preventionTips":["Clear the value field whenever you switch the operator to IS_BLANK.","Validate operator/value pairing in the dashboard before submit.","Centralize condition building so operator semantics are enforced in one place."],"tags":["validation","uri","operator-mismatch"],"backgroundTag":"invalid-argument-value","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"}