{"record":{"id":"b10cbec73ad67407","repo":"apache/shardingsphere","slug":"object-types-cannot-contain-blank-values","errorCode":null,"errorMessage":"object_types cannot contain blank values.","messagePattern":"object_types cannot contain blank values\\.","errorType":"validation","errorClass":"MCPInvalidRequestException","httpStatus":null,"severity":"error","filePath":"mcp/core/src/main/java/org/apache/shardingsphere/mcp/core/tool/request/MCPToolArguments.java","lineNumber":72,"sourceCode":"        }\n        if (!(rawValue instanceof Collection)) {\n            throw new MCPInvalidRequestException(\"object_types must be an array.\");\n        }\n        Collection<?> objectTypes = (Collection<?>) rawValue;\n        if (objectTypes.isEmpty()) {\n            return Collections.emptySet();\n        }\n        Set<SupportedMCPMetadataObjectType> result = new LinkedHashSet<>(objectTypes.size(), 1F);\n        for (Object each : objectTypes) {\n            result.add(resolveObjectType(each, supportedObjectTypes));\n        }\n        return result;\n    }\n    \n    private SupportedMCPMetadataObjectType resolveObjectType(final Object objectType, final Set<SupportedMCPMetadataObjectType> supportedObjectTypes) {\n        String actualValue = Objects.toString(objectType, \"\").trim();\n        if (actualValue.isEmpty()) {\n            throw new MCPInvalidRequestException(\"object_types cannot contain blank values.\");\n        }\n        try {\n            SupportedMCPMetadataObjectType result = SupportedMCPMetadataObjectType.valueOf(actualValue.toUpperCase(Locale.ENGLISH));\n            if (supportedObjectTypes.contains(result)) {\n                return result;\n            }\n        } catch (final IllegalArgumentException ignored) {\n        }\n        throw new MCPInvalidMetadataObjectTypesException(actualValue, createAllowedObjectTypes(supportedObjectTypes));\n    }\n    \n    private List<String> createAllowedObjectTypes(final Set<SupportedMCPMetadataObjectType> supportedObjectTypes) {\n        return supportedObjectTypes.stream().map(each -> each.name().toLowerCase(Locale.ENGLISH)).toList();\n    }\n    \n    /**\n     * Get string argument.\n     *","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/mcp/core/src/main/java/org/apache/shardingsphere/mcp/core/tool/request/MCPToolArguments.java#L54-L90","documentation":"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.","triggerScenarios":"Objects.toString(objectType, \"\").trim().isEmpty() for any array element — e.g. {\"object_types\": [\"table\", \"\"]}, [\"  \"], or a null element inside the array.","commonSituations":"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.","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"],"exampleFix":"// before\nargs.object_types = \"table,\".split(\",\")  // [\"table\", \"\"]\n\n// after\nargs.object_types = \"table,\".split(\",\").filter(s => s.trim());  // [\"table\"]","handlingStrategy":"validation","validationCode":"List<String> cleaned = raw.stream().filter(Objects::nonNull).map(String::trim).filter(s -> !s.isEmpty()).distinct().toList();\nif (cleaned.size() != raw.size()) arguments.put(\"object_types\", cleaned);","typeGuard":null,"tryCatchPattern":"try {\n    listMetadata(arguments);\n} catch (MCPInvalidRequestException e) {\n    if (e.getMessage().contains(\"blank values\")) listMetadata(Map.of(\"object_types\", stripBlanks((List<?>) arguments.get(\"object_types\"))));\n}","preventionTips":["Filter blank/null entries when building arrays (esp. after split of comma lists)","Omit object_types when no filtering is intended"],"tags":["mcp","request-validation","object-types","blank-values","shardingsphere"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}