xai-org/x-algorithm · error · RuntimeError
BDSM_CHALLENGE_SALT env var is required for challenge routin
Error message
BDSM_CHALLENGE_SALT env var is required for challenge routing
What it means
Challenge routing in the focal score sink hashes labels with a salt from the BDSM_CHALLENGE_SALT environment variable. _challenge_salt raises RuntimeError when the var is unset or empty, because unsalted routing would be predictable and gameable.
Source
Thrown at bdsm/runtime/score_results_sink_focal.py:59
def is_active(self, uid):
return False
def is_active_many(self, uids):
return set()
def mark_active(self, uid):
pass
def get_metrics(self):
return {"enabled": False}
_trace = _NoopTrace()
def _challenge_salt() -> bytes:
salt = os.environ.get("BDSM_CHALLENGE_SALT", "")
if not salt:
raise RuntimeError("BDSM_CHALLENGE_SALT env var is required for challenge routing")
return salt.encode()
DEFAULT_BOOTSTRAP = "localhost:9092"
HEAD_NAMES = {
0: "FollowBot",
1: "LikeBot",
2: "EngagementAmplifier",
3: "ReplySpamBot",
4: "TweetSpamBot",
5: "RTBot",
6: "MultiActionBot",
7: "LegitimateUser",
}
def _resolve_head_names(_model_version):View on GitHub (pinned to 24c60942c5)
Solutions
- Set BDSM_CHALLENGE_SALT to the deployment's salt value (from the secret store) before starting the sink
- Add it to the container spec/k8s secret so it is always mounted
- Add a startup preflight assertion for required env vars to fail before any work begins
- Document required env vars in the service runbook
Example fix
# before python -m bdsm.runtime.score_results_sink_focal ... # after export BDSM_CHALLENGE_SALT="$SALT_FROM_SECRET_STORE" python -m bdsm.runtime.score_results_sink_focal ...
Defensive patterns
Strategy: validation
Validate before calling
import os
assert os.environ.get('BDSM_CHALLENGE_SALT'), 'BDSM_CHALLENGE_SALT must be set' Try / catch
try:
salt = _challenge_salt()
except RuntimeError:
salt = load_salt_from_secret_store().encode() Prevention
- Declare the env var in container specs/k8s secrets
- Fail fast on missing env at process start, not at first challenge
- Add a config preflight check to the entrypoint
When it happens
Trigger: Running score_results_sink_focal (or any path reaching pick_challenge_label/_cusp_lane/_paused_head_lane/_spam_bounce_lane) in a process where BDSM_CHALLENGE_SALT is unset or empty; a dotenv file that omits it; the var lost in a container image rebuild.
Common situations: New deployment environment (k8s secret not mounted); local run without copying the env template; secret renamed; CI run lacking prod secrets.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- XAI_USER environment variable is required
- XAI_JOB_NAME environment variable is required
- XAI_CLUSTER environment variable is required
- batch size must be a positive integer
- cannot pass empty collection to Foldl1()
AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28).
Data as JSON: /api/errors/a767c12ae59f9a48.
Report an issue: GitHub.