rusackas opened a new pull request, #42735:
URL: https://github.com/apache/superset/pull/42735

   ### SUMMARY
   Test-only PR pinning the bug reported in #32370 ("Error 505 when exporting 
pivoted .csv with special characters").
   
   Traced the actual mechanism: `QueryContextProcessor.get_data` encodes the 
query's `data` to **bytes** for any CSV `result_format` 
(`superset/common/query_context_processor.py`), and that's exactly the payload 
`ChartDataRestApi._send_chart_response` hands to `apply_client_processing` for 
a `resultType=post_processed` request (i.e. "Export to pivoted .csv"). 
`apply_client_processing`'s CSV branch feeds that straight into 
`StringIO(data)`, which only accepts `str`:
   
   ```
   TypeError: initial_value must be str or None, not bytes
   ```
   
   This reproduces for **every** pivoted CSV export, not only the 
special-character metric labels the issue focuses on — I independently verified 
metric labels containing `%`, `\`, `|` round-trip fine through 
`apply_client_processing` when fed as `str` (matching how the existing unit 
tests in this file construct their input), so the special characters aren't 
actually the trigger. The existing tests never caught this because they 
hand-construct `data` as a plain `str`, which doesn't match what the real query 
pipeline produces for CSV result_format. The new test uses `bytes` (matching 
production) with a `%`-prefixed metric label, so it still pins the originally 
reported symptom.
   
   Root cause fix is not included here — this PR only adds the regression test 
(red on master), per the TDD-PR pattern: a future fix PR should decode `data` 
to `str` before parsing (or have `apply_client_processing` handle both `bytes` 
and `str`), then this test should go green.
   
   ### TESTING INSTRUCTIONS
   ```
   pytest 
tests/unit_tests/charts/test_client_processing.py::test_apply_client_processing_csv_format_bytes_data
   ```
   Currently fails with `TypeError: initial_value must be str or None, not 
bytes` on master.
   
   ### ADDITIONAL INFORMATION
   - [x] Has associated issue: #32370
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API


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