{"record":{"id":"a753891c80bca144","repo":"Hmbown/CodeWhale","slug":"failed-to-validate-runtime-thread-route-reason","errorCode":null,"errorMessage":"Failed to validate runtime thread route: {reason}","messagePattern":"Failed to validate runtime thread route: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/runtime_threads.rs","lineNumber":10047,"sourceCode":"                        route.identity.provider,\n                        &route.candidate.endpoint().base_url,\n                        &route.model,\n                    )\n                    .as_setting()\n                    .to_string()\n            });\n            (\n                route,\n                reasoning_effort,\n                auto_controls_reasoning,\n                crate::cost_status::RuntimeUsageBatch::default(),\n                None,\n            )\n        };\n        let route = if client_preflight_required {\n            route\n                .preflight()\n                .map_err(|reason| anyhow!(\"Failed to validate runtime thread route: {reason}\"))?\n        } else {\n            route\n        };\n        let configured_sandbox_mode = route.config.sandbox_mode.clone();\n        let provider = route.identity.provider;\n        let provider_identity = route.identity.clone();\n        let model = route.model.clone();\n        let route_limits = known_route_limits(route.candidate.limits());\n        let max_output_tokens = req.max_output_tokens.and_then(|requested| {\n            std::num::NonZeroU32::new(crate::route_budget::effective_max_output_tokens_for_turn(\n                provider, &model, route_limits, Some(requested),\n            ))\n        });\n        let settings = crate::settings::Settings::load().unwrap_or_default();\n        let mut compaction = runtime_compaction_config(\n            &route.config,\n            provider,\n            &model,","sourceCodeStart":10029,"sourceCodeEnd":10065,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/runtime_threads.rs#L10029-L10065","documentation":"When a turn start requires client preflight, the resolved route is validated with route.preflight(); any Err becomes 'Failed to validate runtime thread route: {reason}'. Preflight checks that the route's provider/model/sandbox configuration is actually usable from this client before the turn is admitted. This fails the turn start before any engine work happens.","triggerScenarios":"Starting a turn where client_preflight_required is true and route.preflight() rejects the route — e.g. missing API key/credentials for the provider, unreachable provider endpoint configuration, or a route assembled from config that fails runtime validation.","commonSituations":"Missing or expired API key for the selected provider; a config route referencing a model the client cannot serve; proxy/endpoint misconfiguration caught at preflight time; provider removed or renamed in the config.","solutions":["Read the inner {reason} — preflight names the concrete validation failure","Fix the provider credentials/endpoint in config so the route passes preflight","Correct the route configuration (provider, model, sandbox mode) referenced by the thread","If preflight should not be required for this turn, check why client_preflight_required was set rather than skipping it"],"exampleFix":"// before\nlet route = Route::from_config(cfg)?; // fails later at preflight\n// after\nlet route = Route::from_config(cfg)?;\nroute.preflight().map_err(|e| anyhow!(\"route invalid: {e}\"))?; // fail fast, same check","handlingStrategy":"validation","validationCode":"let route = build_route(&config)?;\nroute.preflight().map_err(|e| format!(\"route invalid: {e}\"))?; // same check the runtime runs","typeGuard":null,"tryCatchPattern":"match start_turn(req).await {\n    Err(e) if e.to_string().contains(\"Failed to validate runtime thread route\") => {\n        bail!(\"fix provider/model/credentials in config; preflight rejected the route: {e:#}\");\n    }\n    other => other,\n}","preventionTips":["Run route.preflight() in a startup config check","Keep provider credentials and endpoints current in config","Re-validate routes after upgrading providers or changing sandbox mode"],"tags":["config","validation","routing"],"backgroundTag":"invalid-config-value","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}