codeant-ai-for-open-source[bot] commented on code in PR #40801:
URL: https://github.com/apache/superset/pull/40801#discussion_r3362429054
##########
superset/views/base.py:
##########
@@ -727,12 +727,21 @@ def apply(self, query: Query, value: Any) -> Query:
class CsvResponse(Response):
"""
- Override Response to take into account csv encoding from config.py
+ Response that encodes its body with the configured CSV_EXPORT encoding.
+
+ Werkzeug 3.0 removed ``Response.charset``, which this class relied on,
+ so the configured encoding (e.g. the default "utf-8-sig") was silently
+ ignored and bodies were always plain utf-8.
"""
- charset = app.config["CSV_EXPORT"].get("encoding", "utf-8")
default_mimetype = "text/csv"
+ def __init__(self, response: Any = None, *args: Any, **kwargs: Any) ->
None:
+ encoding = app.config["CSV_EXPORT"].get("encoding", "utf-8")
+ if isinstance(response, str):
+ response = response.encode(encoding)
Review Comment:
✅ **Customized review instruction saved!**
**Instruction:**
> Do not suggest making CSV_EXPORT optional in CsvResponse; it is required
Superset config, so keep direct access and fail loudly on broken config.
**Applied to:**
- `superset/views/base.py`
---
💡 *To manage or update this instruction, visit: [CodeAnt AI
Settings](https://app.codeant.ai/org/settings/learnings)*
--
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]