apache/shenyu · error · IllegalArgumentException
The URI condition value cannot be empty.
Error message
The URI condition value cannot be empty.
What it means
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.
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.
Example fix
// before
UriConditionValidator.validate("regex", null);
// after
UriConditionValidator.validate("regex", "/api/**");
// or for blank checks:
UriConditionValidator.validate("isBlank", null); Defensive patterns
Strategy: validation
Validate before calling
if (!"isBlank".equals(operator) && (value == null || value.isBlank())) { throw new IllegalArgumentException("Operator " + operator + " requires a non-empty URI value"); } Type guard
boolean requiresValue(String operator, String value) { return "isBlank".equals(operator) || (value != null && !value.isBlank()); } Try / catch
try { UriConditionValidator.validate(operator, value); } catch (IllegalArgumentException e) { log.error("Missing URI condition value for operator {}", operator); throw e; } Prevention
- 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.
When it happens
Trigger: Calling UriConditionValidator.validate(operator, value) where operator is anything other than IS_BLANK and value is null, "", or whitespace-only — e.g. validate("regex", " ").
Common situations: 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.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- The URI must start with '/'
- The URI cannot contain whitespaces. Current value: " + value
- The URI must be blank
- namespaceId is null
- namespaceId is not exist
AI-assisted analysis of apache/shenyu@567142e072 (2026-09-12).
Data as JSON: /api/errors/d746b3dccf0ea44f.
Report an issue: GitHub.
Appendix: source
Thrown at shenyu-admin/src/main/java/org/apache/shenyu/admin/validation/validator/UriConditionValidator.java:63
if (StringUtils.isNotBlank(value)) {
throw new IllegalArgumentException("The URI must be blank");
}
};
VALIDATOR_MAP.put(OperatorEnum.PATH_PATTERN.getAlias(),
PathPatternParser.defaultInstance::parse);
VALIDATOR_MAP.put(OperatorEnum.REGEX.getAlias(), Pattern::compile);
VALIDATOR_MAP.put(OperatorEnum.EQ.getAlias(), commonPathValidator);
VALIDATOR_MAP.put(OperatorEnum.STARTS_WITH.getAlias(), commonPathValidator);
VALIDATOR_MAP.put(OperatorEnum.ENDS_WITH.getAlias(), commonPathValidator);
VALIDATOR_MAP.put(OperatorEnum.MATCH.getAlias(), commonPathValidator);
VALIDATOR_MAP.put(OperatorEnum.EXCLUDE.getAlias(), commonPathValidator);
VALIDATOR_MAP.put(OperatorEnum.CONTAINS.getAlias(), commonPathValidator);
VALIDATOR_MAP.put(OperatorEnum.IS_BLANK.getAlias(), blankPathValidator);
}
public static void validate(final String operator, final String value) {
if (!OperatorEnum.IS_BLANK.getAlias().equals(operator) && StringUtils.isBlank(value)) {
throw new IllegalArgumentException("The URI condition value cannot be empty.");
}
Consumer<String> validator = VALIDATOR_MAP.get(operator);
if (Objects.nonNull(validator)) {
validator.accept(value);
}
}
}
View on GitHub (pinned to 567142e072)