{"record":{"id":"cce2233e685179cd","repo":"apache/cassandra","slug":"unknown-direction-s","errorCode":null,"errorMessage":"Unknown direction %s","messagePattern":"Unknown direction (.+?)","errorType":"exception","errorClass":"SyntaxError","httpStatus":null,"severity":"error","filePath":"pylib/cqlshlib/cqlshmain.py","lineNumber":1443,"sourceCode":"        else:\n            # default to all known columns\n            columns = self.get_column_names(ks, table)\n\n        fname = parsed.get_binding('fname', None)\n        if fname is not None:\n            fname = self.cql_unprotect_value(fname)\n\n        copyoptnames = list(map(str.lower, parsed.get_binding('optnames', ())))\n        copyoptvals = list(map(self.cql_unprotect_value, parsed.get_binding('optvals', ())))\n        opts = dict(list(zip(copyoptnames, copyoptvals)))\n\n        direction = parsed.get_binding('dir').upper()\n        if direction == 'FROM':\n            task = ImportTask(self, ks, table, columns, fname, opts, self.conn.protocol_version, self.config_file)\n        elif direction == 'TO':\n            task = ExportTask(self, ks, table, columns, fname, opts, self.conn.protocol_version, self.config_file)\n        else:\n            raise SyntaxError(\"Unknown direction %s\" % direction)\n\n        task.run()\n\n    def do_show(self, parsed):\n        \"\"\"\n        SHOW [cqlsh only]\n\n          Displays information about the current cqlsh session. Can be called in\n          the following ways:\n\n        SHOW VERSION\n\n          Shows the version and build of the connected Cassandra instance, as\n          well as the version of the CQL spec that the connected Cassandra\n          instance understands.\n\n        SHOW HOST\n","sourceCodeStart":1425,"sourceCodeEnd":1461,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/pylib/cqlshlib/cqlshmain.py#L1425-L1461","documentation":"Raised by the COPY command handler in cqlsh when the direction token of the COPY statement is neither FROM (import from CSV) nor TO (export to CSV). cqlsh raises a Python SyntaxError to reject the malformed statement before constructing an ImportTask or ExportTask. It is purely a user-input validation error.","triggerScenarios":"Running `COPY ks.tbl <direction> ...` where the direction keyword is misspelled, lowercased without matching, or missing (e.g. `COPY ks.tbl TO FROM`, `COPY ... frm`, or a direction binding that upper()s to something other than FROM/TO).","commonSituations":"Typo in COPY direction (e.g. `T0`, `form`); scripts generated programmatically with a missing or extra token; pasting partial COPY statements; confusion between COPY direction and file path ordering.","solutions":["Rewrite the COPY statement with an explicit valid direction: `COPY ks.table (cols) FROM 'file.csv' WITH opts;` or `... TO 'file.csv' ...`.","Check that the direction token is the literal word FROM or TO (case-insensitive) immediately after the column list.","If scripting, validate the direction variable before interpolating it into the COPY statement."],"exampleFix":"// before\nCOPY myks.mytable frm 'data.csv';\n// after\nCOPY myks.mytable FROM 'data.csv';","handlingStrategy":"validation","validationCode":"direction = direction.strip().upper()\nif direction not in ('FROM', 'TO'):\n    raise ValueError('COPY direction must be FROM or TO, got %r' % direction)","typeGuard":null,"tryCatchPattern":"try:\n    shell.do_copy(parsed)\nexcept SyntaxError as e:\n    print('COPY statement rejected:', e)","preventionTips":["Always spell COPY direction as FROM or TO immediately after the optional column list.","Template-generated COPY statements: validate the direction variable before interpolation.","Test scripted COPY commands with cqlsh -e before production use."],"tags":["cqlsh","syntax-error","cli","copy-command"],"backgroundTag":"invalid-cli-argument","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}