bito-code-review[bot] commented on PR #43476:
URL: https://github.com/apache/superset/pull/43476#issuecomment-5399020651

   <!-- Bito Reply -->
   The flagged issue is correct. The `normalize_chart_id` function currently 
accepts leading-zero strings (e.g., `"001"`), which can lead to inconsistencies 
if the metadata cleanup logic expects only canonical forms (e.g., `1`).
   
   To resolve this, you should update `normalize_chart_id` to reject strings 
with leading zeros. Here is the corrected implementation:
   
   ```python
   def normalize_chart_id(value: Any) -> int | None:
       """Normalize an integer or canonical decimal-string chart ID."""
       if isinstance(value, bool):
           return None
       if isinstance(value, int):
           return value if value > 0 else None
       if isinstance(value, str) and value.isascii() and value.isdecimal():
           if value != "0" and value.startswith("0"):
               return None
           normalized = int(value)
           return normalized if normalized > 0 else None
       return None
   ```
   
   Would you like me to fetch all other comments on this PR to validate and 
implement fixes for them as well?
   
   **superset/mcp_service/dashboard/layout_validation.py**
   ```
   def normalize_chart_id(value: Any) -> int | None:
       """Normalize an integer or canonical decimal-string chart ID."""
       if isinstance(value, bool):
           return None
       if isinstance(value, int):
           return value if value > 0 else None
       if isinstance(value, str) and value.isascii() and value.isdecimal():
           if value != "0" and value.startswith("0"):
               return None
           normalized = int(value)
           return normalized if normalized > 0 else None
       return None
   ```


-- 
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