{"record":{"id":"7509209abce5343c","repo":"xai-org/x-algorithm","slug":"misconfiguration","errorCode":null,"errorMessage":"{misconfiguration}","messagePattern":"\\{misconfiguration\\}","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"visibility-filtering/server_deps.rs","lineNumber":238,"sourceCode":"        recommendations_rule_count,\n        \"VFServer initialized with prod clients\"\n    );\n\n    VFServer::from_endpoints(\n        FilterTweetsEndpoint::new(filter_tweets, reference_compare),\n        GetSafetyLabelsEndpoint::new(safety_label_source),\n    )\n}\n\nasync fn build_reference_compare_harness(\n    datacenter: &str,\n    init_deadline: tokio::time::Instant,\n) -> Option<Arc<ReferenceCompareHarness>> {\n    let should_build = crate::reference_compare::should_build_harness(\n        crate::config::dual_call_harness_enabled(),\n        std::env::var(\"APP_ENV\").ok().as_deref(),\n    )\n    .unwrap_or_else(|misconfiguration| panic!(\"{misconfiguration}\"));\n    if !should_build {\n        return None;\n    }\n\n    let client_id = format!(\n        \"visibility-filtering-service.{}\",\n        std::env::var(\"APP_ENV\").unwrap_or_else(|_| \"staging\".to_string())\n    );\n    let strato: Arc<dyn VfClient + Send + Sync> = Arc::new(\n        init_client_with_retry(\"strato_vf\", init_deadline, || {\n            let client_id = client_id.clone();\n            async move {\n                StratoVfClient::new(\n                    S2S_CHAIN_PATH.clone(),\n                    S2S_CRT_PATH.clone(),\n                    S2S_KEY_PATH.clone(),\n                    client_id,\n                    datacenter.to_string(),","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/visibility-filtering/server_deps.rs#L220-L256","documentation":"The reference-compare harness is only built when a set of environment/config conditions line up (dual_call_harness_enabled plus the APP_ENV check inside should_build_harness). When should_build_harness returns Err — i.e. the configuration combination is contradictory or invalid — build_reference_compare_harness panics with the misconfiguration message. This is a fail-fast guard against running dual-call comparison in an unsupported environment.","triggerScenarios":"Deploying with the dual-call harness flag enabled but an APP_ENV value that should_build_harness considers invalid or disallowed (e.g. prod, or an unrecognized env name); or enabling the flag in an environment where dual-calling is forbidden. Also hit by the test reference_compare_harness_not_built_without_flag exercising these paths.","commonSituations":"Enabling dual_call_harness in production by accident, setting APP_ENV to an unexpected string, stale flag toggles from a canary config leaking to prod pods.","solutions":["Check the message text: it states which combination (flag + APP_ENV) is invalid; align them — e.g. disable the dual-call harness flag in prod, or set a permitted APP_ENV.","If the harness is intended for this environment, fix the APP_ENV value to one should_build_harness accepts.","Audit config precedence (env vars vs flag files) to ensure the harness flag is not unintentionally on."],"exampleFix":"// before\n.unwrap_or_else(|misconfiguration| panic!(\"{misconfiguration}\"));\n\n// after: degrade gracefully instead of aborting server startup\nlet should_build = match crate::reference_compare::should_build_harness(\n    crate::config::dual_call_harness_enabled(),\n    std::env::var(\"APP_ENV\").ok().as_deref(),\n) {\n    Ok(v) => v,\n    Err(misconfiguration) => {\n        tracing::error!(\"{misconfiguration}; skipping reference compare harness\");\n        return None;\n    }\n};","handlingStrategy":"validation","validationCode":"use visibility_filtering::reference_compare::should_build_harness;\n\nfn harness_config_ok() -> Result<bool, String> {\n    should_build_harness(\n        dual_call_harness_enabled(),\n        std::env::var(\"APP_ENV\").ok().as_deref(),\n    )\n}\n// call before build_prod_server(); log/abort on Err before the panic path","typeGuard":null,"tryCatchPattern":"let harness = std::panic::catch_unwind(|| build_reference_compare_harness(/* deps */))\n    .unwrap_or_else(|_| { tracing::error!(\"harness misconfigured; starting without it\"); None });","preventionTips":["Gate dual-call harness flags per environment in config management, not ad-hoc env edits.","Validate APP_ENV + harness flag combinations in a startup config check.","Add deployment checks that refuse to enable comparison harnessing in disallowed envs.","Test flag/env matrix in CI (the crate already has reference_compare_harness_not_built_without_flag)."],"tags":["rust","configuration","env-var","feature-flag","startup","panic","visibility-filtering"],"backgroundTag":"invalid-feature-flag-combination","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}