nicolargo/glances · warning · ValueError
replication_factor must be a positive integer
Error message
replication_factor must be a positive integer
What it means
The Cassandra export requires replication_factor to parse as an int >= 1; anything else (0, negative, non-numeric string) raises this ValueError, which is caught in the same __init__, logged as 'Cassandra configuration error', and results in the export being disabled (export_enable = False). Glances itself continues to run.
Source
Thrown at glances/exports/glances_cassandra/__init__.py:69
self.username = None
self.password = None
# Load the Cassandra configuration file section
self.export_enable = self.load_conf(
'cassandra',
mandatories=['host', 'port', 'keyspace'],
options=['protocol_version', 'replication_factor', 'table', 'username', 'password'],
)
if not self.export_enable:
sys.exit(2)
# Validate CQL identifiers to prevent injection via config values
try:
self.keyspace = _validate_cql_identifier(self.keyspace, 'keyspace')
self.table = _validate_cql_identifier(self.table, 'table')
self.replication_factor = int(self.replication_factor)
if self.replication_factor < 1:
raise ValueError("replication_factor must be a positive integer")
except ValueError as e:
logger.error(f"Cassandra configuration error: {e}")
self.export_enable = False
return
# Init the Cassandra client
self.cluster, self.session = self.init()
def init(self):
"""Init the connection to the Cassandra server."""
if not self.export_enable:
return None
# if username and/or password are not set the connection will try to connect with no auth
auth_provider = PlainTextAuthProvider(username=self.username, password=self.password)
# Cluster
try:View on GitHub (pinned to a240d8dfb3)
Solutions
- Set a positive integer, e.g. export_cassandra_replication_factor=1 (or 3 for production clusters).
- Verify the key in glances.conf is spelled export_cassandra_replication_factor and holds a bare integer.
- Check glances.log for 'Cassandra configuration error' to confirm validation failed and the export was disabled.
Example fix
# before [export_cassandra] replication_factor=0 # after [export_cassandra] replication_factor=1
Defensive patterns
Strategy: validation
Validate before calling
rf = int(config.get('replication_factor', 1))
assert rf >= 1, 'replication_factor must be >= 1' Type guard
def is_valid_replication_factor(v) -> bool:
try:
return int(v) >= 1
except (TypeError, ValueError):
return False Prevention
- Single-node clusters: use replication_factor=1, never 0.
- Keep the value a bare integer in glances.conf (no quotes/units).
- After config changes, verify in glances.log that the export actually enabled.
When it happens
Trigger: Setting export_cassandra_replication_factor to 0, -1, 'two', or omitting a default that resolves falsy in glances.conf. Also triggered if the config value has stray whitespace or quotes that break int().
Common situations: Single-node test clusters where users set replication_factor=0 thinking it means 'no replication'; config typos like replication_factor = 1; environments with more than one datacenter but a simple-int config.
Related errors
AI-assisted analysis of nicolargo/glances@a240d8dfb3 (2026-08-27).
Data as JSON: /api/errors/6cae6c85ae2c9adf.
Report an issue: GitHub.