Skip to content

Fix xlsx_errors column overwriting the last data column#2181

Closed
prajakta128 wants to merge 1 commit into
aboutcode-org:mainfrom
prajakta128:fix/xlsx-errors-col-overwrites-last-data-column
Closed

Fix xlsx_errors column overwriting the last data column#2181
prajakta128 wants to merge 1 commit into
aboutcode-org:mainfrom
prajakta128:fix/xlsx-errors-col-overwrites-last-data-column

Conversation

@prajakta128

Copy link
Copy Markdown

What

Fix xlsx_errors column writing error messages to the wrong column, overwriting the last data column's value.

Why

errors_col_index = len(fields) - 1 points to the last data column (zero-indexed). But xlsx_errors is appended AFTER all fields, so its correct index is len(fields).

For example with 3 fields [col_a, col_b, col_c]:

  • Column index 2 = col_c (last data column) ← bug writes here
  • Column index 3 = xlsx_errors ← should write here

How to reproduce

Export any project to XLSX where a field value exceeds 32,767 chars. The truncation error message overwrites col_c instead of appearing in the xlsx_errors column.

Fix

One line changed in scanpipe/pipes/output.py:

  • errors_col_index = len(fields) - 1
  • errors_col_index = len(fields)

Added a regression test in scanpipe/tests/pipes/test_output.py.

Fixes #2088

errors_col_index was set to len(fields) - 1 which points to the
last data column, not the xlsx_errors column. The xlsx_errors
column is appended after all fields, so its correct index is
len(fields).

Add a regression test to verify the error message lands in the
correct column and does not overwrite data.

Fixes aboutcode-org#2088

Signed-off-by: Prajakta Kamble <prajuu2812@gmail.com>
@prajakta128 prajakta128 force-pushed the fix/xlsx-errors-col-overwrites-last-data-column branch from cf09e4c to fc66d11 Compare June 25, 2026 05:00
@prajakta128

Copy link
Copy Markdown
Author

I noticed PR #2117 addresses the same issue but has not been merged yet.
My PR takes a similar approach. Happy to collaborate or close this one
if the maintainers prefer to proceed with #2117.

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.

XLSX export truncations overwrite the last data column.

1 participant