bito-code-review[bot] commented on code in PR #37245:
URL: https://github.com/apache/superset/pull/37245#discussion_r3418901227


##########
superset/commands/report/execute.py:
##########
@@ -506,6 +506,20 @@ def _get_pdf(self) -> bytes:
 
         return pdf
 
+    def _ensure_utf8_bom(self, csv_data: bytes, encoding: str) -> bytes:
+        """
+        Ensure CSV bytes contain UTF-8 BOM when encoding is utf-8-sig.
+        Avoid double BOM.
+        """
+        if not csv_data:
+            return csv_data
+
+        enc = (encoding or "").lower().replace("_", "-")
+        if enc in ("utf-8-sig", "utf8-sig"):
+            if not csv_data.startswith(b"\xef\xbb\xbf"):
+                return b"\xef\xbb\xbf" + csv_data
+        return csv_data

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Missing unit tests for new method</b></div>
   <div id="fix">
   
   New method `_ensure_utf8_bom` lacks unit tests. Per BITO.md rule [11730], 
new functionality must include tests covering success paths, error scenarios, 
and edge cases. Add tests to `tests/unit_tests/commands/report/execute_test.py`.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #2c602d</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



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