pola-rs/polars · error · ValueError
cannot set truncate_ragged_lines=False with…
Error message
cannot set truncate_ragged_lines=False with extra_columns='ignore'
What it means
The unstable `extra_columns='ignore'` mode of `scan_csv` works by internally truncating ragged lines, so explicitly setting `truncate_ragged_lines=False` together with it is contradictory. Polars raises this ValueError rather than silently overriding one of the options.
Solutions
- Omit `truncate_ragged_lines` (leave it None) when using `extra_columns='ignore'` — polars sets it to True automatically.
- If you truly need `truncate_ragged_lines=False`, switch `extra_columns` to the default `"raise"` (or "warn").
- Decide which behavior you want: either tolerate ragged rows (truncation) or error on them.
Example fix
// before
pl.scan_csv("f.csv", extra_columns="ignore", truncate_ragged_lines=False)
// after
pl.scan_csv("f.csv", extra_columns="ignore") Defensive patterns
Strategy: validation
Validate before calling
if extra_columns == "ignore":
truncate_ragged_lines = None # let polars default it to True Prevention
- Don't hard-set truncate_ragged_lines in shared config when extra_columns is configurable.
- Understand that extra_columns='ignore' implies truncating overlong rows.
- Keep unstable-parameter usage isolated and commented.
When it happens
Trigger: `pl.scan_csv(..., extra_columns="ignore", truncate_ragged_lines=False)` — the caller explicitly disables ragged-line truncation while asking polars to ignore surplus columns, which requires truncation.
Common situations: Copy-pasting option sets from different examples; a config layer that always sets `truncate_ragged_lines=False` while another layer enables `extra_columns='ignore'`; misunderstanding that 'ignore extra columns' implies dropping cells on overlong rows.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
Related errors
- cannot set both `with_column_names` and `new_columns`…
- `schema_overrides` should be of type list or dict, got
- =" " should be a single byte character or empty, but is…
- =" " should be a single byte character, but is bytes long
- can not match overlapping patterns when leftmost == True
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/afb138a1d8391350.
Report an issue: GitHub.
Appendix: source
Thrown at py-polars/src/polars/io/csv/functions.py:878
if isinstance(source, (str, Path)):
source = normalize_filepath(source, check_not_directory=False)
elif is_path_or_str_sequence(source, allow_str=False):
source = [
normalize_filepath(source, check_not_directory=False) for source in source
]
if not infer_schema:
infer_schema_length = 0
if extra_columns is not None:
msg = "The `extra_columns` parameter of `scan_csv` is considered unstable."
issue_unstable_warning(msg)
else:
extra_columns = "raise"
if extra_columns == "ignore" and truncate_ragged_lines is False:
msg = "cannot set truncate_ragged_lines=False with extra_columns='ignore'"
raise ValueError(msg)
if truncate_ragged_lines is None:
truncate_ragged_lines = extra_columns == "ignore"
if missing_columns is not None:
msg = "The `missing_columns` parameter of `scan_csv` is considered unstable."
issue_unstable_warning(msg)
credential_provider_builder = _init_credential_provider_builder(
credential_provider, source, storage_options, "scan_csv"
)
del credential_provider
dtype_list: list[tuple[str, PolarsDataType]] | None = None
dtype_slice: Sequence[PolarsDataType] | None = None
if schema_overrides is not None:
if isinstance(schema_overrides, dict):
dtype_list = []View on GitHub (pinned to fe841f959e)