Skip to content

fix(declarative): raise CSV decoder field size limit and attribute overflows - #1116

Draft
devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1786558917-csv-field-size-limit
Draft

fix(declarative): raise CSV decoder field size limit and attribute overflows#1116
devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1786558917-csv-field-size-limit

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

The declarative CsvDecoder's parser built a csv.DictReader without ever calling csv.field_size_limit, so it inherited CPython's 131,072-character default. Any low-code/manifest-only connector streaming a CSV response with a field longer than that failed the sync. The file-based CDK parser has raised the limit to 2**31 since airbytehq/airbyte#36320; the declarative parser never got the same treatment.

Confirmed locally that the failure is a hard error, not silent truncation — feeding a 200,000-character field through the reader exactly as the parser does raises _csv.Error: field larger than field limit (131072), and nothing in the CDK catches csv.Error, so it escaped through the generic handler with no attribution.

Three changes:

  1. CsvParser.max_field_size defaults to 2**31, matching the file-based parser.
  2. New optional max_field_size property on CsvDecoder (schema + regenerated model + ModelToComponentFactory), so a manifest can tune it. Existing manifests are unaffected.
  3. Overflow now raises an actionable AirbyteTracedException (config_error) instead of a bare _csv.Error:
message="CSV field exceeds the configured maximum size of 2147483648 characters."
internal_message=str(exc)  # "field larger than field limit (2147483648)"

Python's csv module reports neither the offending column nor the observed field size, so the message names only the constraint it can actually attribute. Non-field-limit csv.Errors propagate unchanged.

Note on process-global state

csv.field_size_limit() mutates module-global state in _csv. Rather than mutating it at construction time (what the file-based parser does), this sets the limit at the start of the parse and restores the prior value in a finally, so the decoder doesn't leave a surprising limit in place for other parsers in the same process:

previous_field_size_limit = csv.field_size_limit(max_field_size)
try:
    ...  # reader constructed AND fully iterated inside, since parse() is a generator
finally:
    csv.field_size_limit(previous_field_size_limit)

The limit must be in effect for the whole iteration, not just reader construction, because parse yields lazily.

Scope note: the parser keeps its # TODO: migrate implementation to re-use file-base classes comment — that migration is deliberately not attempted here.

Test Coverage

Added to unit_tests/sources/declarative/decoders/test_composite_decoder.py: a 200,000-character field parses successfully with the new default; a low max_field_size override is honored and produces the traced exception with the expected message and FailureType; and the global csv.field_size_limit() is restored after parsing.

Related to https://github.com/airbytehq/oncall/issues/13293:

Originating community discussion: airbytehq/airbyte#84337 (reporter Juan (@jnr0790)). Product tracking: https://github.com/airbytehq/product-request-backlog/issues/115.

Requested by Devin Bot via the /ai-fix workflow. Suggested reviewers based on recent history in composite_raw_decoder.py: aldogonzalez8 (added set_values_to_none to this same parser), and Anatolii Yatsuk.

Link to Devin session: https://app.devin.ai/sessions/ad59c78feefe40a9abef98654ae80402

devin-ai-integration Bot and others added 2 commits August 12, 2026 18:27
Co-Authored-By: bot_apk <apk@cognition.ai>
Co-Authored-By: bot_apk <apk@cognition.ai>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@github-actions

Copy link
Copy Markdown

👋 Greetings, Airbyte Team Member!

Here are some helpful tips and reminders for your convenience.

💡 Show Tips and Tricks

Testing This CDK Version

You can test this version of the CDK using the following:

# Run the CLI from this branch:
uvx 'git+https://github.com/airbytehq/airbyte-python-cdk.git@devin/1786558917-csv-field-size-limit#egg=airbyte-python-cdk[dev]' --help

# Update a connector to use the CDK from this branch ref:
cd airbyte-integrations/connectors/source-example
poe use-cdk-branch devin/1786558917-csv-field-size-limit

PR Slash Commands

Airbyte Maintainers can execute the following slash commands on your PR:

  • /autofix - Fixes most formatting and linting issues
  • /poetry-lock - Updates poetry.lock file
  • /test - Runs connector tests with the updated CDK
  • /prerelease - Triggers a prerelease publish with default arguments
  • /poe build - Regenerate git-committed build artifacts, such as the pydantic models which are generated from the manifest JSON schema in YAML.
  • /poe <command> - Runs any poe command in the CDK environment
📚 Show Repo Guidance

Helpful Resources

📝 Edit this welcome message.

@github-actions

Copy link
Copy Markdown

PyTest Results (Fast)

4 232 tests  +3   4 220 ✅ +3   8m 17s ⏱️ -7s
    1 suites ±0      12 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit 2a0ab06. ± Comparison against base commit 68bc294.

@github-actions

Copy link
Copy Markdown

PyTest Results (Full)

4 235 tests  +3   4 223 ✅ +3   12m 28s ⏱️ -19s
    1 suites ±0      12 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit 2a0ab06. ± Comparison against base commit 68bc294.

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

Cross-reference: #1114 was opened from a separate Devin session for the same oncall issue and covers a subset of this change (raises the limit, no CsvDecoder manifest property and no actionable error on overflow). These two should not both land — flagging for maintainers to pick one.


Devin session

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants