apache/shardingsphere · error · MCPInvalidRequestException
target_status is required for readwrite-splitting status.
Error message
target_status is required for readwrite-splitting status.
What it means
Thrown by ReadwriteSplittingStatusDistSQLPlanningService.planStatus when resolveStatusOperation cannot resolve an ENABLE or DISABLE operation from the request, so no ALTER READWRITE_SPLITTING RULE ... ENABLE/DISABLE ... statement can be generated. It is an MCPInvalidRequestException: the request shape is incomplete for the status workflow.
Source
Thrown at mcp/features/readwrite-splitting/src/main/java/org/apache/shardingsphere/mcp/feature/readwritesplitting/tool/service/ReadwriteSplittingStatusDistSQLPlanningService.java:42
import java.util.Locale;
/**
* Readwrite-splitting status DistSQL planning service.
*/
public final class ReadwriteSplittingStatusDistSQLPlanningService {
/**
* Plan readwrite-splitting storage-unit status artifact.
*
* @param request status workflow request
* @return rule artifact
* @throws MCPInvalidRequestException when no status operation can be resolved
*/
public RuleArtifact planStatus(final ReadwriteSplittingStatusWorkflowRequest request) {
String operation = resolveStatusOperation(request);
if (operation.isEmpty()) {
throw new MCPInvalidRequestException("target_status is required for readwrite-splitting status.");
}
return new RuleArtifact(operation.toLowerCase(Locale.ENGLISH), String.format("ALTER READWRITE_SPLITTING RULE %s %s %s FROM %s",
WorkflowSQLUtils.formatGeneratedRuleDistSQLIdentifier(request.getRuleName()), operation,
WorkflowSQLUtils.formatGeneratedRuleDistSQLIdentifier(request.getStorageUnit()), WorkflowSQLUtils.formatGeneratedRuleDistSQLIdentifier(request.getDatabase())));
}
/**
* Resolve ENABLE or DISABLE operation from request fields.
*
* @param request status workflow request
* @return DistSQL status operation
*/
public String resolveStatusOperation(final ReadwriteSplittingStatusWorkflowRequest request) {
return normalizeStatusOperation(request.getTargetStatus());
}
private String normalizeStatusOperation(final String status) {
String actualStatus = status.trim().toLowerCase(Locale.ENGLISH);View on GitHub (pinned to e952770a21)
Solutions
- Set target_status to ENABLE or DISABLE (exact tokens the resolver accepts) on the status workflow request.
- Run the tool's schema/descriptor first and populate every required field, especially target_status, before invoking.
- Check the request class (ReadwriteSplittingStatusWorkflowRequest) field names in your version and match them exactly.
Example fix
// before
request.setTargetStatus("");
// after
request.setTargetStatus("DISABLE"); Defensive patterns
Strategy: validation
Validate before calling
String op = resolveStatusOperationLocally(request); // "ENABLE", "DISABLE" or ""
if (op.isEmpty()) { throw new IllegalArgumentException("target_status must be ENABLE or DISABLE"); } Type guard
const hasTargetStatus = r => ["ENABLE", "DISABLE"].includes((r?.target_status ?? "").toUpperCase());
Try / catch
try {
planningService.planStatus(request);
} catch (final MCPInvalidRequestException ex) {
// 'target_status is required...' -> set request.setTargetStatus("ENABLE"|"DISABLE") and retry
} Prevention
- Treat target_status as mandatory for status workflows, not optional
- Validate against the request class fields of the exact deployed version
- Build requests through typed builders rather than raw maps
When it happens
Trigger: Invoking the readwrite-splitting status tool without target_status (or with a value that maps to neither ENABLE nor DISABLE) while providing rule/storage unit/database fields — the planner resolves the operation from the request fields and gets an empty string.
Common situations: Agents omitting target_status assuming the tool defaults to DISABLE, passing "status": "disabled" or a boolean instead of the expected field, or schema drift after the status tool's request type changed.
Related errors
- Either key generator name or algorithm segment must be provi
- 1
- 0
- Completion argument `%s` is not declared for %s `%s`.
- database_gateway_execute_query only supports parser-approved
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/26f4b68ce6a1c0ec.
Report an issue: GitHub.