{"record":{"id":"aaeae9e3c2f8d1ef","repo":"apache/cassandra","slug":"failed-to-parse-s-s","errorCode":null,"errorMessage":"Failed to parse %s : %s","messagePattern":"Failed to parse (.+?) : (.+?)","errorType":"validation","errorClass":"ParseError","httpStatus":null,"severity":"error","filePath":"pylib/cqlshlib/copyutil.py","lineNumber":2182,"sourceCode":"\n        for i in self.primary_key_indexes:\n            if row[i] == self.nullval:\n                raise ParseError(self.get_null_primary_key_message(i))\n\n        def convert(c, v):\n            try:\n                return c(v) if v != self.nullval else self.get_null_val()\n            except Exception as e:\n                # if we could not convert an empty string, then self.nullval has been set to a marker\n                # because the user needs to import empty strings, except that the converters for some types\n                # will fail to convert an empty string, in this case the null value should be inserted\n                # see CASSANDRA-12794\n                if v == '':\n                    return self.get_null_val()\n\n                if self.debug:\n                    traceback.print_exc()\n                raise ParseError(\"Failed to parse %s : %s\" % (v, e.message if hasattr(e, 'message') else str(e)))\n\n        return [convert(conv, val) for conv, val in zip(converters, row)]\n\n    def get_null_primary_key_message(self, idx):\n        message = \"Cannot insert null value for primary key column '%s'.\" % (self.columns[idx],)\n        if self.nullval == '':\n            message += \" If you want to insert empty strings, consider using\" \\\n                       \" the WITH NULL=<marker> option for COPY.\"\n        return message\n\n    def get_row_partition_key_values_fcn(self):\n        \"\"\"\n        Return a function to convert a row into a string composed of the partition key values serialized\n        and binary packed (the tokens on the ring). Depending on whether we are using prepared statements, we\n        may have to convert the primary key values first, so we have two different serialize_value implementations.\n        We also return different functions depending on how many partition key indexes we have (single or multiple).\n        See also BoundStatement.routing_key.\n        \"\"\"","sourceCodeStart":2164,"sourceCodeEnd":2200,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/pylib/cqlshlib/copyutil.py#L2164-L2200","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)"],"exampleFix":"// before (int column)\n1,twelve\n// after\n1,12","handlingStrategy":"try-catch","validationCode":"# pre-validate cell values against column types before COPY\nfor col, v, t in zip(columns, row, types):\n    try:\n        coerce(t, v)\n    except Exception as e:\n        raise ValueError(f\"{col}={v!r} not valid {t}: {e}\")","typeGuard":null,"tryCatchPattern":"try:\n    run_copy_from(...)\nexcept ParseError as e:\n    msg = str(e)\n    value, cause = msg.split(' : ', 1)\n    log.error(f\"Fix CSV value {value}; cause: {cause}\")","preventionTips":["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)"],"tags":["cqlsh","copy","parsing","type-mismatch"],"backgroundTag":"invalid-argument-value","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}