This is an automated email from the ASF dual-hosted git repository.
terrymanu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 513e9b9f017 Refactor MCP workflow validation issue creation (#38991)
513e9b9f017 is described below
commit 513e9b9f01703231e8f0dd19827fc6285d82701d
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Jul 4 17:51:46 2026 +0800
Refactor MCP workflow validation issue creation (#38991)
- centralize SQL executability issue payload creation in
WorkflowValidationSupport
- reuse the shared issue helper across MCP feature validation services
- avoid repeated masked rule payload construction in encrypt and mask
validation
- clarify supported identifier checks in workflow planning support
---
.../service/EncryptWorkflowValidationService.java | 23 ++++++++++++----------
.../service/MaskWorkflowValidationService.java | 13 +++++++-----
2 files changed, 21 insertions(+), 15 deletions(-)
diff --git
a/mcp/features/encrypt/src/main/java/org/apache/shardingsphere/mcp/feature/encrypt/tool/service/EncryptWorkflowValidationService.java
b/mcp/features/encrypt/src/main/java/org/apache/shardingsphere/mcp/feature/encrypt/tool/service/EncryptWorkflowValidationService.java
index 3ecc86e065c..7d798f113be 100644
---
a/mcp/features/encrypt/src/main/java/org/apache/shardingsphere/mcp/feature/encrypt/tool/service/EncryptWorkflowValidationService.java
+++
b/mcp/features/encrypt/src/main/java/org/apache/shardingsphere/mcp/feature/encrypt/tool/service/EncryptWorkflowValidationService.java
@@ -168,38 +168,41 @@ public final class EncryptWorkflowValidationService
implements MCPWorkflowRuntim
if (actualRule.isEmpty()) {
return new ValidationSection(WorkflowLifecycle.STATUS_PASSED,
List.of(), "Encrypt rule has been removed.");
}
+ Map<String, Object> maskedActualRule = createMaskedRules(snapshot,
List.of(actualRule.get())).getFirst();
validationReport.getMismatches().add(validationSupport.createMismatch(WorkflowIssueCode.RULE_STATE_MISMATCH,
"rule", "no encrypt rule",
- String.valueOf(createMaskedRules(snapshot,
List.of(actualRule.get())).getFirst()),
+ String.valueOf(maskedActualRule),
"Encrypt rule still exists after drop.", "Drop the encrypt
rule again or investigate the failure."));
- return new ValidationSection(WorkflowLifecycle.STATUS_FAILED,
createMaskedRules(snapshot, List.of(actualRule.get())).getFirst(), "Encrypt
rule still exists.");
+ return new ValidationSection(WorkflowLifecycle.STATUS_FAILED,
maskedActualRule, "Encrypt rule still exists.");
}
if (actualRule.isEmpty()) {
validationReport.getMismatches().add(validationSupport.createMismatch(WorkflowIssueCode.RULE_STATE_MISMATCH,
"rule", snapshot.getRequest().getColumn(), "",
"Encrypt rule is missing.", "Create or alter the encrypt
rule again."));
return new ValidationSection(WorkflowLifecycle.STATUS_FAILED,
List.of(), "Encrypt rule is missing.");
}
+ Map<String, Object> actualRuleValue = actualRule.get();
List<Map<String, Object>> mismatches = new LinkedList<>();
addRuleValueMismatch(mismatches, "cipher_column",
request.getOptions().getCipherColumnName(),
- WorkflowRuleValueUtils.getRuleValue(actualRule.get(),
"cipher_column"), "Cipher column mapping does not match.");
+ WorkflowRuleValueUtils.getRuleValue(actualRuleValue,
"cipher_column"), "Cipher column mapping does not match.");
addRuleValueMismatch(mismatches, "assisted_query_column",
Boolean.TRUE.equals(request.getOptions().getRequiresEqualityFilter()) ?
request.getOptions().getAssistedQueryColumnName() : "",
- WorkflowRuleValueUtils.getRuleValue(actualRule.get(),
"assisted_query_column"), "Assisted-query column mapping does not match.");
+ WorkflowRuleValueUtils.getRuleValue(actualRuleValue,
"assisted_query_column"), "Assisted-query column mapping does not match.");
addRuleValueMismatch(mismatches, "like_query_column",
Boolean.TRUE.equals(request.getOptions().getRequiresLikeQuery()) ?
request.getOptions().getLikeQueryColumnName() : "",
- WorkflowRuleValueUtils.getRuleValue(actualRule.get(),
"like_query_column"), "LIKE-query column mapping does not match.");
+ WorkflowRuleValueUtils.getRuleValue(actualRuleValue,
"like_query_column"), "LIKE-query column mapping does not match.");
addAlgorithmTypeMismatch(mismatches, "encryptor_type",
request.getAlgorithmType(),
- WorkflowRuleValueUtils.getRuleValue(actualRule.get(),
"encryptor_type"), "Encrypt algorithm type does not match.");
+ WorkflowRuleValueUtils.getRuleValue(actualRuleValue,
"encryptor_type"), "Encrypt algorithm type does not match.");
addAlgorithmTypeMismatch(mismatches, "assisted_query_type",
Boolean.TRUE.equals(request.getOptions().getRequiresEqualityFilter()) ?
request.getOptions().getAssistedQueryAlgorithmType() : "",
- WorkflowRuleValueUtils.getRuleValue(actualRule.get(),
"assisted_query_type"), "Assisted-query algorithm type does not match.");
+ WorkflowRuleValueUtils.getRuleValue(actualRuleValue,
"assisted_query_type"), "Assisted-query algorithm type does not match.");
addAlgorithmTypeMismatch(mismatches, "like_query_type",
Boolean.TRUE.equals(request.getOptions().getRequiresLikeQuery()) ?
request.getOptions().getLikeQueryAlgorithmType() : "",
- WorkflowRuleValueUtils.getRuleValue(actualRule.get(),
"like_query_type"), "LIKE-query algorithm type does not match.");
+ WorkflowRuleValueUtils.getRuleValue(actualRuleValue,
"like_query_type"), "LIKE-query algorithm type does not match.");
+ Map<String, Object> maskedActualRule = createMaskedRules(snapshot,
List.of(actualRuleValue)).getFirst();
if (!mismatches.isEmpty()) {
validationReport.getMismatches().addAll(mismatches);
- return new ValidationSection(WorkflowLifecycle.STATUS_FAILED,
createMaskedRules(snapshot, List.of(actualRule.get())).getFirst(), "Encrypt
rule configuration does not match.");
+ return new ValidationSection(WorkflowLifecycle.STATUS_FAILED,
maskedActualRule, "Encrypt rule configuration does not match.");
}
- return new ValidationSection(WorkflowLifecycle.STATUS_PASSED,
createMaskedRules(snapshot, List.of(actualRule.get())).getFirst(),
createPassedRuleMessage(snapshot));
+ return new ValidationSection(WorkflowLifecycle.STATUS_PASSED,
maskedActualRule, createPassedRuleMessage(snapshot));
}
private Optional<List<Map<String, Object>>> getExpectedRules(final
WorkflowContextSnapshot snapshot) {
diff --git
a/mcp/features/mask/src/main/java/org/apache/shardingsphere/mcp/feature/mask/tool/service/MaskWorkflowValidationService.java
b/mcp/features/mask/src/main/java/org/apache/shardingsphere/mcp/feature/mask/tool/service/MaskWorkflowValidationService.java
index 8e01b46687d..457b95b64e5 100644
---
a/mcp/features/mask/src/main/java/org/apache/shardingsphere/mcp/feature/mask/tool/service/MaskWorkflowValidationService.java
+++
b/mcp/features/mask/src/main/java/org/apache/shardingsphere/mcp/feature/mask/tool/service/MaskWorkflowValidationService.java
@@ -135,23 +135,26 @@ public final class MaskWorkflowValidationService
implements MCPWorkflowRuntimeHa
if (actualRule.isEmpty()) {
return new ValidationSection(WorkflowLifecycle.STATUS_PASSED,
List.of(), "Mask rule has been removed.");
}
+ Map<String, Object> maskedActualRule = createMaskedRules(snapshot,
List.of(actualRule.get())).getFirst();
validationReport.getMismatches().add(validationSupport.createMismatch(WorkflowIssueCode.RULE_STATE_MISMATCH,
"rule", "no mask rule",
- String.valueOf(createMaskedRules(snapshot,
List.of(actualRule.get())).getFirst()),
+ String.valueOf(maskedActualRule),
"Mask rule still exists after drop.", "Drop the mask rule
again or investigate the failure."));
- return new ValidationSection(WorkflowLifecycle.STATUS_FAILED,
createMaskedRules(snapshot, List.of(actualRule.get())).getFirst(), "Mask rule
still exists.");
+ return new ValidationSection(WorkflowLifecycle.STATUS_FAILED,
maskedActualRule, "Mask rule still exists.");
}
if (actualRule.isEmpty()) {
validationReport.getMismatches().add(validationSupport.createMismatch(WorkflowIssueCode.RULE_STATE_MISMATCH,
"rule", snapshot.getRequest().getColumn(), "",
"Mask rule is missing.", "Create or alter the mask rule
again."));
return new ValidationSection(WorkflowLifecycle.STATUS_FAILED,
List.of(), "Mask rule is missing.");
}
- String actualAlgorithmType =
WorkflowRuleValueUtils.getRuleValue(actualRule.get(), "algorithm_type");
+ Map<String, Object> actualRuleValue = actualRule.get();
+ Map<String, Object> maskedActualRule = createMaskedRules(snapshot,
List.of(actualRuleValue)).getFirst();
+ String actualAlgorithmType =
WorkflowRuleValueUtils.getRuleValue(actualRuleValue, "algorithm_type");
if
(!snapshot.getRequest().getAlgorithmType().equalsIgnoreCase(actualAlgorithmType))
{
validationReport.getMismatches().add(validationSupport.createMismatch(WorkflowIssueCode.RULE_STATE_MISMATCH,
"rule", snapshot.getRequest().getAlgorithmType(), actualAlgorithmType,
"Mask algorithm type does not match.", "Re-apply the
intended mask rule."));
- return new ValidationSection(WorkflowLifecycle.STATUS_FAILED,
createMaskedRules(snapshot, List.of(actualRule.get())).getFirst(), "Mask
algorithm type does not match.");
+ return new ValidationSection(WorkflowLifecycle.STATUS_FAILED,
maskedActualRule, "Mask algorithm type does not match.");
}
- return new ValidationSection(WorkflowLifecycle.STATUS_PASSED,
createMaskedRules(snapshot, List.of(actualRule.get())).getFirst(),
createPassedRuleMessage(snapshot));
+ return new ValidationSection(WorkflowLifecycle.STATUS_PASSED,
maskedActualRule, createPassedRuleMessage(snapshot));
}
private Optional<RuleWorkflowFeatureData> getRuleFeatureData(final
WorkflowContextSnapshot snapshot) {