Skip to content

fix: csv import honors MAX_RECORD instead of a fixed 1KB line cap (#67) - #69

Merged
mscasso-scanoss merged 1 commit into
crc64from
fix/issue-67-csv-max-record
Oct 26, 2026
Merged

mscasso-scanoss merged 1 commit into
crc64from
fix/issue-67-csv-max-record

Conversation

@mscasso-scanoss

Copy link
Copy Markdown
Collaborator

Summary

Fixes #67. bulk insert from CSV silently skipped every line longer than 1,023 bytes (a fixed MAX_CSV_LINE_LEN cap applied to the whole getline() line), ignoring MAX_RECORD. Records that should fit (e.g. with MAX_RECORD=2048) were lost, and the skip was only logged at debug level — invisible unless VERBOSE was on.

Changes

  • Remove the fixed 1 KB whole-line cap in ldb_import_csv (src/import.c). The lower bound (line too short to hold a key + separators) is kept; the upper bound now follows MAX_RECORD.
  • Enforce MAX_RECORD on the record data size (r_size), consistent with collate's size > max_rec_ln filter. Hard-capped by the 2-byte record-size field (LDB_MAX_REC_LN).
  • No more silent drops: an oversized record is counted in the import summary and logged at info level.
  • data_bin grows with the line buffer instead of being a fixed 1 KB stack array, so binary (.enc/base64) records are no longer truncated.
  • Drop the now-dead MAX_CSV_LINE_LEN define from src/import.c (kept in the public definitions.h to avoid breaking consumers).
  • Bump version to 5.0.3-crc64; document the MAX_RECORD import behaviour in README.md.

Testing

  • New regression test test_12_import_respects_max_record_not_fixed_line_len in test/test_kb: lines of 1000/1100/2000/3000 bytes imported with MAX_RECORD=2048 — the 1100 and 2000-byte records (dropped by the old cap) are now stored; the 3000-byte one (data > MAX_RECORD) is skipped, counted, and logged.
  • Reproduced the bug against crc64 HEAD (lines ≥1024 dropped) and confirmed the fix.
  • Full suite (./run_test.sh, both MD5 and CRC64 knowledge bases) passes: Overall result: SUCCESS.

Note: on crc64, collate.c already uses LDB_MAX_REC_LN-sized buffers, so (unlike master) the tuple_bin resize mentioned in the issue is not needed here.

🤖 Generated with Claude Code

bulk insert silently skipped every CSV line longer than 1,023 bytes via a
fixed MAX_CSV_LINE_LEN cap applied to the whole getline() line, ignoring
MAX_RECORD. Records that should fit (e.g. with MAX_RECORD=2048) were lost,
and the skip was only logged at debug level.

The upper bound now follows MAX_RECORD and is enforced on the record data
size, consistent with collate (size > max_rec_ln). Oversized records are
counted in the import summary and logged at info level instead of being
dropped in silence. The base64 decode buffer (data_bin) grows with the line
buffer instead of being a fixed 1 KB stack array, so binary records are no
longer truncated.

Adds test_12 to test/test_kb, bumps version to 5.0.3-crc64, and documents
the MAX_RECORD import behaviour in README.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mscasso-scanoss mscasso-scanoss self-assigned this Oct 26, 2026
@mscasso-scanoss
mscasso-scanoss merged commit 01bbcc3 into crc64 Oct 26, 2026
1 check passed
@mscasso-scanoss
mscasso-scanoss deleted the fix/issue-67-csv-max-record branch October 26, 2026 14:40
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.

1 participant