apache/cassandra · error · ValueError

Invalid boolean styles %s

Error message

Invalid boolean styles %s

What it means

COPY options validation in cqlsh's CopyHelper rejects a BOOLSTYLE option that is not exactly two distinct, non-empty tokens. The boolstyle option defines the strings used for true/false when exporting or importing CSV data, so both markers must be present and different to disambiguate values.

Source

Thrown at pylib/cqlshlib/copyutil.py:400

        # responds: here we set it to 1 sec per 10 rows but no less than 60 seconds
        copy_options['requesttimeout'] = int(opts.pop('requesttimeout', max(60, 1 * copy_options['maxbatchsize'] / 10)))
        # set childtimeout higher than requesttimeout so that child processes have a chance to report request timeouts
        copy_options['childtimeout'] = int(opts.pop('childtimeout', copy_options['requesttimeout'] + 30))

        self.check_options(copy_options)
        return CopyOptions(copy=copy_options, dialect=dialect_options, unrecognized=opts)

    @staticmethod
    def check_options(copy_options):
        """
        Check any options that require a sanity check beyond a simple type conversion and if required
        raise a value error:

        - boolean styles must be exactly 2, they must be different and they cannot be empty
        """
        bool_styles = copy_options['boolstyle']
        if len(bool_styles) != 2 or bool_styles[0] == bool_styles[1] or not bool_styles[0] or not bool_styles[1]:
            raise ValueError("Invalid boolean styles %s" % copy_options['boolstyle'])

    @staticmethod
    def get_num_processes(cap):
        """
        Pick a reasonable number of child processes. We need to leave at
        least one core for the parent or feeder process.
        """
        return max(1, min(cap, CopyTask.get_num_cores() - 1))

    @staticmethod
    def get_num_cores():
        """
        Return the number of cores if available. If the test environment variable
        is set, then return the number carried by this variable. This is to test single-core
        machine more easily.
        """
        try:
            num_cores_for_testing = os.environ.get('CQLSH_COPY_TEST_NUM_CORES', '')

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Provide exactly two distinct non-empty styles, e.g. BOOLSTYLE='True,False'
  2. Remove the BOOLSTYLE option to use the default (true/false)
  3. Check quoting so the two styles are parsed as two separate tokens, not one string

Example fix

// before
COPY t (a,b) TO 'out.csv' WITH BOOLSTYLE='true';
// after
COPY t (a,b) TO 'out.csv' WITH BOOLSTYLE='true,false';
Defensive patterns

Strategy: validation

Validate before calling

styles = options.get('boolstyle', 'true,false').split(',')
assert len(styles) == 2 and styles[0] and styles[1] and styles[0] != styles[1], "BOOLSTYLE needs two distinct non-empty styles"

Prevention

When it happens

Trigger: Running COPY TO/COPY FROM with `BOOLSTYLE='true,false'` variants that fail validation: only one style given, both styles identical (e.g. 'yes,yes'), an empty style (e.g. 'true,'), or an otherwise malformed value that does not split into 2 items.

Common situations: Users typo the option as BOOLSTYLE=truefalse, quote it incorrectly so it parses as a single token, copy an example with 't,f' but drop a comma, or set it via a cqlshrc/config file with an empty half.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/42b69522253d1417. Report an issue: GitHub.