{"record":{"id":"5d6cd514e71d35e1","repo":"openai/codex","slug":"collaboration-mode-default-template-must-render","errorCode":null,"errorMessage":"collaboration mode default template must render: {err}","messagePattern":"collaboration mode default template must render: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"codex-rs/models-manager/src/collaboration_mode_presets.rs","lineNumber":44,"sourceCode":"        developer_instructions: Some(Some(COLLABORATION_MODE_PLAN.to_string())),\n    }\n}\n\nfn default_preset() -> CollaborationModeMask {\n    CollaborationModeMask {\n        name: ModeKind::Default.display_name().to_string(),\n        mode: Some(ModeKind::Default),\n        model: None,\n        reasoning_effort: None,\n        developer_instructions: Some(Some(default_mode_instructions())),\n    }\n}\n\nfn default_mode_instructions() -> String {\n    let known_mode_names = format_mode_names(&TUI_VISIBLE_COLLABORATION_MODES);\n    COLLABORATION_MODE_DEFAULT_TEMPLATE\n        .render([(KNOWN_MODE_NAMES_TEMPLATE_KEY, known_mode_names.as_str())])\n        .unwrap_or_else(|err| panic!(\"collaboration mode default template must render: {err}\"))\n}\n\nfn format_mode_names(modes: &[ModeKind]) -> String {\n    let mode_names: Vec<&str> = modes.iter().map(|mode| mode.display_name()).collect();\n    match mode_names.as_slice() {\n        [] => \"none\".to_string(),\n        [mode_name] => (*mode_name).to_string(),\n        [first, second] => format!(\"{first} and {second}\"),\n        [..] => mode_names.join(\", \"),\n    }\n}\n\n#[cfg(test)]\n#[path = \"collaboration_mode_presets_tests.rs\"]\nmod tests;\n","sourceCodeStart":26,"sourceCodeEnd":60,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/models-manager/src/collaboration_mode_presets.rs#L26-L60","documentation":"The default collaboration-mode template parsed, but rendering it with the single supplied key (KNOWN_MODE_NAMES) failed, panicking inside default_mode_instructions(). In practice this means the template references a placeholder other than KNOWN_MODE_NAMES, or syntax that only fails at substitution time. Like the parse panic, both inputs are compile-time constants (the DEFAULT template and TUI_VISIBLE_COLLABORATION_MODES), so hitting this means a crate invariant was broken by a template edit, not by runtime data.","triggerScenarios":"DEFAULT references any placeholder other than {{KNOWN_MODE_NAMES}} (default_mode_instructions() passes exactly one key/value pair to render), or a renamed KNOWN_MODE_NAMES_TEMPLATE_KEY left the template text stale. The panic surfaces on the first call to builtin_collaboration_mode_presets().","commonSituations":"Adding a new placeholder to the prompt without extending the render tuple; renaming the key constant; a template grammar that defers some validation from parse time to render time.","solutions":["Make every placeholder in DEFAULT exactly KNOWN_MODE_NAMES, or extend the render tuple in default_mode_instructions() with the new key when intentionally adding one.","Run the preset tests so the failure is caught at test time instead of first user request.","If a rename happened, grep the template text for the old placeholder name and update it."],"exampleFix":"// before: template uses a placeholder the renderer never supplies\n// const DEFAULT: &str = \"Modes: {{MODE_LIST}}\";\n// after: match the one key default_mode_instructions() renders\n// const DEFAULT: &str = \"Modes: {{KNOWN_MODE_NAMES}}\";","handlingStrategy":"validation","validationCode":"// Render with the exact key production code supplies; fails in CI if the template drifts\n#[test]\nfn default_template_renders_with_known_key() {\n    COLLABORATION_MODE_DEFAULT_TEMPLATE\n        .render([(KNOWN_MODE_NAMES_TEMPLATE_KEY, \"Plan and Default\")])\n        .expect(\"default template must render\");\n}","typeGuard":null,"tryCatchPattern":"Panic, not an error value: do not attempt to catch. Fix by aligning every placeholder in the template with the keys passed in default_mode_instructions().","preventionTips":["When adding a placeholder to the template, extend the render tuple in the same commit.","After renaming KNOWN_MODE_NAMES_TEMPLATE_KEY, grep the template constants for the old name.","Keep a render test as the tripwire in collaboration_mode_presets_tests.rs."],"tags":["rust","codex","template","render","panic"],"backgroundTag":"template-render-missing-variable","analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}