Skip to content

Skip CSVs with fewer than six columns in folder uploads instead of sending them as annotations - #583

Merged
iurisilvio merged 3 commits into
mainfrom
iuri/roboflow-python-folder-csv
Nov 16, 2026
Merged

iurisilvio merged 3 commits into
mainfrom
iuri/roboflow-python-folder-csv

Conversation

@iurisilvio

Copy link
Copy Markdown
Contributor

What does this PR do?

Failure. The annotate API answers some folder-upload annotation saves with a 500, TypeError: Cannot read properties of undefined (reading 'width'). In the last 30 days, 938 of them came from roboflow-python/1.7.3 folder uploads in two workspaces (555 on 2026-10-27, 383 on 2026-11-08). Each is a name=annotation.csv save whose body is a CSV header plus one row of a metadata table: a filename followed by three or four values such as a split, a count, scores or a status, with no box columns. roboflow/roboflow#19525 makes the API answer 400 for these; this PR stops the SDK from sending them.

Root cause. parsefolder reads every .csv other than _classes.csv as an annotation CSV: each image named in its first column gets the header plus its rows as annotation.csv. A metadata CSV in the folder becomes the annotation of every image it lists, and when it sorts before the folder's annotation CSV (/metadata.csv before /train/_annotations.csv), it is used in that CSV's place. The server's CSV parser reads boxes only from rows of six or more columns, so these rows hold no annotation.

Fix. _loadAnnotations reads a CSV as annotations only when it is _classes.csv (multi-label classification, which the SDK reads itself) or its first line has at least six columns, the fewest of any box layout the server reads (RetinaNet and VoTT have six, Tensorflow Object Detection eight). It skips other CSVs and prints warning: skipping <file>: annotation CSVs have at least six columns, like the parser's other warnings. Their images upload with the folder's other annotations, or without one. An empty CSV, which raised IndexError, is skipped the same way.

Changed files:

  • roboflow/util/folderparser.py: _is_annotation_csv, used by _loadAnnotations.
  • tests/util/test_folderparser.py: the regression test.
  • CHANGELOG.md: a Fixed entry.

Related Issue(s): roboflow/roboflow#19525 (the API half: 400 instead of 500).

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Testing

  • I have tested this change locally
  • I have added/updated tests for this change

Test details:

  • test_parse_csv_skips_metadata_csv: a folder with two images, train/_annotations.csv (Tensorflow layout, a row for a.jpg) and metadata.csv (four columns, rows for both images). a.jpg gets the _annotations.csv row, b.jpg gets no annotation, and the warning names /metadata.csv. On main it fails: a.jpg gets the metadata row.
  • python -m unittest: 1280 tests OK, 1 skipped (Python 3.12, macOS); tests.util.test_folderparser also passes on Python 3.10. make check_code_quality passes, and so do the pre-commit pins (ruff 0.15.10, bandit 1.9.4).
  • On throwaway folders, a headerless RetinaNet CSV, a VoTT CSV, a Tensorflow CSV with other header names and a two-class _classes.csv pair with the same images, with the same text, on main and on this branch.
  • Not run against staging or production.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in hard-to-understand areas
  • My changes generate no new warnings or errors
  • I have updated the documentation accordingly (if applicable): not applicable

Additional Context

🤖 Generated with Claude Code

iurisilvio and others added 2 commits November 13, 2026 19:01
The folder parser sends the rows of every CSV other than _classes.csv as
the annotation of the images they name. A table of image metadata in the
folder fails every listed image's annotation save, and when it sorts
before the folder's annotation CSV it is used in that CSV's place.

The server's CSV parser reads boxes only from rows of six or more
columns, so the folder parser now reads a CSV as annotations only when it
is _classes.csv or has at least six columns, and skips other CSVs with a
warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@iurisilvio iurisilvio self-assigned this Nov 13, 2026
@iurisilvio
iurisilvio requested a review from a team November 13, 2026 19:46
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@iurisilvio
iurisilvio merged commit 9415946 into main Nov 16, 2026
15 checks passed
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