aminghadersohi commented on code in PR #39915:
URL: https://github.com/apache/superset/pull/39915#discussion_r3211964828


##########
superset/mcp_service/chart/validation/schema_validator.py:
##########
@@ -525,6 +525,38 @@ def _pre_validate_mixed_timeseries_config(
 
         return True, None
 
+    @staticmethod
+    def _format_single_error(err: Dict[str, Any]) -> tuple[str, str]:
+        """Return (detail_message, optional_suggestion) for one pydantic 
error."""
+        loc_parts = [str(p) for p in err.get("loc", [])]
+        loc = " -> ".join(loc_parts)
+        msg = err.get("msg", "Validation failed")
+        err_type = err.get("type", "")
+        field = loc_parts[-1] if loc_parts else "field"
+
+        if err_type == "string_pattern_mismatch":
+            return (
+                f"'{field}' value contains disallowed characters. "
+                "Column names must not contain HTML, script tags, or SQL "
+                "injection patterns. Use the exact column name from your 
dataset.",
+                "Use get_dataset_info to find exact column names",
+            )

Review Comment:
   Fixed in ff7ace5c7d: now extracts the actual regex pattern from Pydantic's 
error context (`err["ctx"]["pattern"]`) and includes it in the message 
dynamically instead of hardcoding it.
   
   Example output: `'name' value does not match the required format (required 
pattern: \`^[a-zA-Z0-9_][a-zA-Z0-9_\\s\\-\\.]*$\`).`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to