apache/shardingsphere · error · MCPInvalidRequestException
object_types cannot contain blank values.
Error message
object_types cannot contain blank values.
What it means
Thrown by MCPToolArguments.resolveObjectType as MCPInvalidRequestException when an object_types array entry trims to an empty string. Blank entries (empty strings or whitespace-only) are rejected explicitly so a silently ignored filter value cannot cause an unexpected metadata scope.
Source
Thrown at mcp/core/src/main/java/org/apache/shardingsphere/mcp/core/tool/request/MCPToolArguments.java:72
}
if (!(rawValue instanceof Collection)) {
throw new MCPInvalidRequestException("object_types must be an array.");
}
Collection<?> objectTypes = (Collection<?>) rawValue;
if (objectTypes.isEmpty()) {
return Collections.emptySet();
}
Set<SupportedMCPMetadataObjectType> result = new LinkedHashSet<>(objectTypes.size(), 1F);
for (Object each : objectTypes) {
result.add(resolveObjectType(each, supportedObjectTypes));
}
return result;
}
private SupportedMCPMetadataObjectType resolveObjectType(final Object objectType, final Set<SupportedMCPMetadataObjectType> supportedObjectTypes) {
String actualValue = Objects.toString(objectType, "").trim();
if (actualValue.isEmpty()) {
throw new MCPInvalidRequestException("object_types cannot contain blank values.");
}
try {
SupportedMCPMetadataObjectType result = SupportedMCPMetadataObjectType.valueOf(actualValue.toUpperCase(Locale.ENGLISH));
if (supportedObjectTypes.contains(result)) {
return result;
}
} catch (final IllegalArgumentException ignored) {
}
throw new MCPInvalidMetadataObjectTypesException(actualValue, createAllowedObjectTypes(supportedObjectTypes));
}
private List<String> createAllowedObjectTypes(final Set<SupportedMCPMetadataObjectType> supportedObjectTypes) {
return supportedObjectTypes.stream().map(each -> each.name().toLowerCase(Locale.ENGLISH)).toList();
}
/**
* Get string argument.
*View on GitHub (pinned to e952770a21)
Solutions
- Filter out null/blank entries before sending: array.filter(s => s && s.trim())
- Fix the source of the empty entries (trailing commas, unfilled form fields)
- If no filtering is desired, omit object_types entirely — absence returns the empty/full default per the tool contract
Example fix
// before
args.object_types = "table,".split(",") // ["table", ""]
// after
args.object_types = "table,".split(",").filter(s => s.trim()); // ["table"] Defensive patterns
Strategy: validation
Validate before calling
List<String> cleaned = raw.stream().filter(Objects::nonNull).map(String::trim).filter(s -> !s.isEmpty()).distinct().toList();
if (cleaned.size() != raw.size()) arguments.put("object_types", cleaned); Try / catch
try {
listMetadata(arguments);
} catch (MCPInvalidRequestException e) {
if (e.getMessage().contains("blank values")) listMetadata(Map.of("object_types", stripBlanks((List<?>) arguments.get("object_types"))));
} Prevention
- Filter blank/null entries when building arrays (esp. after split of comma lists)
- Omit object_types when no filtering is intended
When it happens
Trigger: Objects.toString(objectType, "").trim().isEmpty() for any array element — e.g. {"object_types": ["table", ""]}, [" "], or a null element inside the array.
Common situations: Client-side array building that leaves trailing empty entries (split of a trailing comma: "table,".split(",")); form inputs submitted with an empty selection; agent-generated lists containing nulls.
Related errors
- object_types must be an array.
- Unsupported object_types value `%s`.
- Statement is not a transaction command.
- %s must be an integer between %d and %d.
- Metadata introspection SQL should use MCP metadata resources
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/b10cbec73ad67407.
Report an issue: GitHub.