Skip to content

Preserve every row in multi-file CSV responses - #577

Merged
CyMule merged 6 commits into
mainfrom
fix/preserve-multi-file-csv-rows
Jul 23, 2026
Merged

Preserve every row in multi-file CSV responses#577
CyMule merged 6 commits into
mainfrom
fix/preserve-multi-file-csv-rows

Conversation

@CyMule

@CyMule CyMule commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • concatenate each uploaded file's partition rows in request order
  • serialize CSV output without a leading unnamed pandas index column
  • tolerate a file that produces no elements instead of failing the request
  • add regression coverage for duplicate filenames and empty-element files

Why

CSV output for a multi-file request was built by outer-merging each file's
DataFrame into the previous one (data.merge(resp_data, how="outer")). An outer
merge joins on the intersection of columns, so identical rows across files
collapsed into a single row and legitimate duplicate rows were silently dropped
— most visibly when two uploads shared a filename. The merge also emitted the
row index as a leading unnamed column.

Impact

Multi-file CSV responses now retain every row from every file (including
duplicates and repeated filenames), union differing columns, and no longer
contain the extra unnamed index column. A file that produces no elements
contributes no rows rather than failing the whole request.

Validation

  • pytest test_general/api/test_app.py::test_output_format_csv_concatenates_multiple_files_without_index_column — 1 passed
  • pytest test_general/api/test_app.py::test_output_format_csv_keeps_rows_when_one_file_has_no_elements — 1 passed

CyMule added 4 commits July 19, 2026 21:18
A file whose partition produces zero elements serializes to a bodiless
CSV that pandas cannot parse, which failed the entire multi-file request.
Such partitions now contribute no rows while every row from the remaining
files is preserved.
@CyMule
CyMule marked this pull request as ready for review July 21, 2026 00:46

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Shadow auto-approve: would auto-approve. Fixes a bug in CSV multi-file output by replacing an outer merge with row concatenation, preserving all rows and removing the unnamed index column. Change is bounded, well-tested, and clearly beneficial.

Re-trigger cubic

@paulkarayan paulkarayan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits:

  • the CHANGELOG/description says results "union differing columns," but neither new test exercises files with different column sets. should be a quick llm addition
  • line 753 item

if response.body.strip()
]
if not frames:
return PlainTextResponse(responses[0].body)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:
do you need the response? PlainTextResponse("") seems like it would suit

@CyMule
CyMule enabled auto-merge (squash) July 23, 2026 02:44
@CyMule
CyMule merged commit 0830d20 into main Jul 23, 2026
11 checks passed
@CyMule
CyMule deleted the fix/preserve-multi-file-csv-rows branch July 23, 2026 03:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants