{"record":{"id":"836ae536967b8b28","repo":"block/buzz","slug":"bundled-model-capabilities-json-must-parse","errorCode":null,"errorMessage":"bundled model-capabilities.json must parse","messagePattern":"bundled model-capabilities\\.json must parse","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/buzz-agent/src/model_capabilities.rs","lineNumber":238,"sourceCode":"pub struct CapabilityResult {\n    pub thinking_mode: ThinkingMode,\n    pub supported_efforts: &'static [ThinkingEffort],\n    pub default_effort: Option<ThinkingEffort>,\n    pub databricks_v2_wire_route: DatabricksV2Route,\n    pub normalization_policy: NormalizationPolicy,\n    pub registry_label: Option<&'static str>,\n}\n\nconst MANIFEST_JSON: &str = include_str!(\"../../../scripts/model-capabilities.json\");\n\nstatic MANIFEST: OnceLock<Manifest> = OnceLock::new();\n\n/// Parse (once) and return the embedded manifest. Panics on a malformed or\n/// invalid bundled manifest — a build-time data error that must never ship.\nfn manifest() -> &'static Manifest {\n    MANIFEST.get_or_init(|| {\n        let parsed: Manifest = serde_json::from_str(MANIFEST_JSON)\n            .expect(\"bundled model-capabilities.json must parse\");\n        if let Err(e) = validate_manifest(&parsed) {\n            panic!(\"bundled model-capabilities.json failed validation: {e}\");\n        }\n        parsed\n    })\n}\n\n/// Canonicalize a provider name: trim, lowercase, apply the alias map.\nfn canonical_provider(provider: &str) -> String {\n    let canon = provider.trim().to_ascii_lowercase();\n    match canon.as_str() {\n        \"openai-compat\" => \"openai\".to_string(),\n        \"databricks-v2\" => \"databricks_v2\".to_string(),\n        _ => canon,\n    }\n}\n\n/// Strip an endpoint-naming prefix by locating the earliest family token that","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/block/buzz/blob/dad5a33865fc81a2e55b3b60746632f615ec1e3a/crates/buzz-agent/src/model_capabilities.rs#L220-L256","documentation":"buzz-agent embeds scripts/model-capabilities.json at compile time via include_str! and lazily parses it in manifest() behind a OnceLock. A malformed JSON file makes serde_json::from_str return Err and the .expect panics with this message on the first capability lookup (validation failures panic separately). The comment states the intent: this is a build-time data error that must never ship — it indicates the repo's bundled manifest was corrupted, not a user input problem.","triggerScenarios":"Editing scripts/model-capabilities.json and introducing a syntax error (trailing comma, unescaped quote, broken UTF-8), then building and running buzz-agent: the binary compiles fine (include_str! just embeds bytes) but panics on the first call that needs model capabilities, e.g. clamping output tokens or selecting context windows for a model.","commonSituations":"Hand-editing the manifest to add a new model; a merge conflict in the JSON resolved with conflict markers left inside; CI green on compile but the smoke run panics because nothing in the build validates JSON syntax.","solutions":["Validate the manifest before building: `jq . scripts/model-capabilities.json >/dev/null` — jq exits non-zero on syntax errors.","Fix the reported JSON error at the exact location (serde's expect prints line/column in the panic).","Add a unit test or CI step that runs the same validate_manifest() used in manifest() so a broken file fails the build, not first use.","After fixing, rebuild — the corrected file is re-embedded by include_str!."],"exampleFix":"# before: broken JSON ships and panics on first use\n# thread panicked: bundled model-capabilities.json must parse at line 12 column 3\nvi scripts/model-capabilities.json   # remove trailing comma at line 12\n\n# after: gate it in CI\njq . scripts/model-capabilities.json > /dev/null || exit 1\ncargo build -p buzz-agent","handlingStrategy":"validation","validationCode":"# CI/build gate: fail before shipping a broken manifest\njq . scripts/model-capabilities.json > /dev/null\ncargo test -p buzz-agent model_capabilities","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never hand-edit the bundled JSON without running jq/serde validation afterwards.","Add a build.rs or CI check that parses scripts/model-capabilities.json so it fails the build, not first use at runtime.","Cover validate_manifest() with tests that reject malformed/invalid manifests, keeping the panic path truly unreachable.","Treat any occurrence in the wild as a release-process gap: the binary should never have been cut."],"tags":["rust","json","build-data","panic","embedded-resource","validation"],"backgroundTag":"bundled-json-invalid","analyzedSha":"dad5a33865fc81a2e55b3b60746632f615ec1e3a","analyzedAt":"2026-08-20T04:38:24.874Z","contentChangedAt":"2026-08-20T04:38:24.874Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}