{"record":{"id":"208e8e6b2f4224be","repo":"nicolargo/glances","slug":"invalid-cql-identifier-for-name-value-r-on","errorCode":null,"errorMessage":"Invalid CQL identifier for '{name}': {value!r}. Only letters, digits, and underscores are allowed, and it must start with a letter.","messagePattern":"Invalid CQL identifier for '(.+?)': (.+?)\\. Only letters, digits, and underscores are allowed, and it must start with a letter\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"glances/exports/glances_cassandra/__init__.py","lineNumber":30,"sourceCode":"import sys\nfrom datetime import datetime\nfrom numbers import Number\n\nfrom cassandra import InvalidRequest\nfrom cassandra.auth import PlainTextAuthProvider\nfrom cassandra.cluster import Cluster\nfrom cassandra.util import uuid_from_time\n\nfrom glances.exports.export import GlancesExport\nfrom glances.logger import logger\n\n_CQL_IDENTIFIER_RE = re.compile(r'^[a-zA-Z][a-zA-Z0-9_]*$')\n\n\ndef _validate_cql_identifier(value, name):\n    \"\"\"Raise ValueError if value is not a safe CQL identifier.\"\"\"\n    if not _CQL_IDENTIFIER_RE.match(str(value)):\n        raise ValueError(\n            f\"Invalid CQL identifier for '{name}': {value!r}. \"\n            \"Only letters, digits, and underscores are allowed, and it must start with a letter.\"\n        )\n    return str(value)\n\n\nclass Export(GlancesExport):\n    \"\"\"This class manages the Cassandra/Scylla export module.\"\"\"\n\n    def __init__(self, config=None, args=None):\n        \"\"\"Init the Cassandra export IF.\"\"\"\n        super().__init__(config=config, args=args)\n\n        # Mandatory configuration keys (additional to host and port)\n        self.keyspace = None\n\n        # Optional configuration keys\n        self.protocol_version = 3","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/nicolargo/glances/blob/a240d8dfb3105a38b5964357ec21768594b0e83e/glances/exports/glances_cassandra/__init__.py#L12-L48","documentation":"The Cassandra export validates keyspace and table names against ^[a-zA-Z][a-zA-Z0-9_]*$ to prevent CQL injection through configuration values. Any keyspace/table containing hyphens, dots, spaces, quotes, or starting with a digit/underscore raises this ValueError from __init__. The outer __init__ catches it, logs 'Cassandra configuration error', and disables the export (export_enable = False), so Glances keeps running without Cassandra export.","triggerScenarios":"Setting export_cassandra_keyspace or export_cassandra_table in glances.conf to values like 'my-keyspace', 'glances.table', '1space', or '_t'. Only plain identifiers are accepted — no quoting, no dotted keyspaces.","commonSituations":"Pointing Glances at an existing keyspace whose real name contains a hyphen (common in Cassandra naming), or copy-pasting a table name with quotes/spaces from CQLSH.","solutions":["Rename the keyspace/table to match [a-zA-Z][a-zA-Z0-9_]* (e.g. my_keyspace instead of my-keyspace).","If you must keep a non-conforming name, create a compatible view/table alias in Cassandra or patch _validate_cql_identifier locally — upstream intentionally rejects it for injection safety.","Check glances.log for 'Cassandra configuration error' to confirm this validation is what disabled the export."],"exampleFix":"# before\n[export_cassandra]\nkeyspace=glances-data\n\n# after\n[export_cassandra]\nkeyspace=glances_data","handlingStrategy":"validation","validationCode":"import re\n_CQL = re.compile(r'^[a-zA-Z][a-zA-Z0-9_]*$')\nassert _CQL.match(keyspace) and _CQL.match(table), 'use plain CQL identifiers'","typeGuard":"def is_valid_cql_identifier(v: str) -> bool:\n    return bool(re.match(r'^[a-zA-Z][a-zA-Z0-9_]*$', v))","tryCatchPattern":null,"preventionTips":["Use snake_case identifiers for Glances-managed keyspaces/tables.","Validate config values at deploy time with the same regex.","Check glances.log for 'Cassandra configuration error' — validation failure silently disables the export."],"tags":["cassandra","cql","config-validation","injection-prevention"],"backgroundTag":"identifier-validation-failed","analyzedSha":"a240d8dfb3105a38b5964357ec21768594b0e83e","analyzedAt":"2026-08-27T19:15:19.178Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}