apache/cassandra · error · ParseError
Failed to parse %s : %s
Error message
Failed to parse %s : %s
What it means
Generic catch-all raised when converting a CSV cell during COPY FROM fails for any reason. The original exception is reported inline (e.message if present, else str(e)) after the raw value, e.g. a non-numeric string for an int column.
Source
Thrown at pylib/cqlshlib/copyutil.py:2182
for i in self.primary_key_indexes:
if row[i] == self.nullval:
raise ParseError(self.get_null_primary_key_message(i))
def convert(c, v):
try:
return c(v) if v != self.nullval else self.get_null_val()
except Exception as e:
# if we could not convert an empty string, then self.nullval has been set to a marker
# because the user needs to import empty strings, except that the converters for some types
# will fail to convert an empty string, in this case the null value should be inserted
# see CASSANDRA-12794
if v == '':
return self.get_null_val()
if self.debug:
traceback.print_exc()
raise ParseError("Failed to parse %s : %s" % (v, e.message if hasattr(e, 'message') else str(e)))
return [convert(conv, val) for conv, val in zip(converters, row)]
def get_null_primary_key_message(self, idx):
message = "Cannot insert null value for primary key column '%s'." % (self.columns[idx],)
if self.nullval == '':
message += " If you want to insert empty strings, consider using" \
" the WITH NULL=<marker> option for COPY."
return message
def get_row_partition_key_values_fcn(self):
"""
Return a function to convert a row into a string composed of the partition key values serialized
and binary packed (the tokens on the ring). Depending on whether we are using prepared statements, we
may have to convert the primary key values first, so we have two different serialize_value implementations.
We also return different functions depending on how many partition key indexes we have (single or multiple).
See also BoundStatement.routing_key.
"""View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Read the embedded cause after the ':' to see the real conversion failure and fix that value in the CSV
- Rerun with cqlsh --debug to get the full traceback
- Align the CSV values with the column types (or use suitable COPY options like DATEFORMAT, FLOATPRECISION, NULLS)
Example fix
// before (int column) 1,twelve // after 1,12
Defensive patterns
Strategy: try-catch
Validate before calling
# pre-validate cell values against column types before COPY
for col, v, t in zip(columns, row, types):
try:
coerce(t, v)
except Exception as e:
raise ValueError(f"{col}={v!r} not valid {t}: {e}") Try / catch
try:
run_copy_from(...)
except ParseError as e:
msg = str(e)
value, cause = msg.split(' : ', 1)
log.error(f"Fix CSV value {value}; cause: {cause}") Prevention
- Rerun with --debug for full tracebacks when debugging
- Sample-validate a few rows against the schema before a big import
- Keep value formats consistent with column types (ISO dates, plain numerics)
When it happens
Trigger: Any conversion failure inside the per-column converter/protector: 'abc' for an int column, malformed UUID, out-of-range numeric, bad timestamp format, invalid IP for inet, etc.
Common situations: Type mismatches between CSV data and the table schema, exported values in a format the importer's converter doesn't accept (e.g. different timestamp precision), locale-formatted numbers with commas as thousand separators.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Empty values are not allowed
- Invalid composite string, it should start and end with match
- can't interpret %r as a date with format %s or as int
- Invalid row length %d should be %d
- Value '%s' can't be converted to integer.
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/aaeae9e3c2f8d1ef.
Report an issue: GitHub.