{"record":{"id":"3fe2017549b4605a","repo":"openai/codex","slug":"collaboration-mode-default-template-must-parse-e","errorCode":null,"errorMessage":"collaboration mode default template must parse: {err}","messagePattern":"collaboration mode default template must parse: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"codex-rs/models-manager/src/collaboration_mode_presets.rs","lineNumber":13,"sourceCode":"use codex_collaboration_mode_templates::DEFAULT as COLLABORATION_MODE_DEFAULT;\nuse codex_collaboration_mode_templates::PLAN as COLLABORATION_MODE_PLAN;\nuse codex_protocol::config_types::CollaborationModeMask;\nuse codex_protocol::config_types::ModeKind;\nuse codex_protocol::config_types::TUI_VISIBLE_COLLABORATION_MODES;\nuse codex_protocol::openai_models::ReasoningEffort;\nuse codex_utils_template::Template;\nuse std::sync::LazyLock;\n\nconst KNOWN_MODE_NAMES_TEMPLATE_KEY: &str = \"KNOWN_MODE_NAMES\";\nstatic COLLABORATION_MODE_DEFAULT_TEMPLATE: LazyLock<Template> = LazyLock::new(|| {\n    Template::parse(COLLABORATION_MODE_DEFAULT)\n        .unwrap_or_else(|err| panic!(\"collaboration mode default template must parse: {err}\"))\n});\n\npub fn builtin_collaboration_mode_presets() -> Vec<CollaborationModeMask> {\n    vec![plan_preset(), default_preset()]\n}\n\nfn plan_preset() -> CollaborationModeMask {\n    CollaborationModeMask {\n        name: ModeKind::Plan.display_name().to_string(),\n        mode: Some(ModeKind::Plan),\n        model: None,\n        reasoning_effort: Some(Some(ReasoningEffort::Medium)),\n        developer_instructions: Some(Some(COLLABORATION_MODE_PLAN.to_string())),\n    }\n}\n\nfn default_preset() -> CollaborationModeMask {\n    CollaborationModeMask {","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/models-manager/src/collaboration_mode_presets.rs#L1-L31","documentation":"A process-aborting panic raised from a LazyLock the first time the embedded default collaboration-mode prompt template is parsed. The template is the compile-time constant codex_collaboration_mode_templates::DEFAULT, so a parse failure means the shipped template text itself is malformed -- a broken crate-level invariant, not something user input or runtime state can trigger. It fires on the first code path that touches COLLABORATION_MODE_DEFAULT_TEMPLATE, i.e. builtin_collaboration_mode_presets()/default_mode_instructions() in codex-rs/models-manager/src/collaboration_mode_presets.rs.","triggerScenarios":"Editing the DEFAULT template constant and introducing invalid template syntax (unbalanced or malformed placeholder delimiters), then building any binary that renders the builtin collaboration-mode presets. Template::parse returns Err and the unwrap_or_else panics with the parser error appended to the message.","commonSituations":"Prompt-template editing sessions where delimiters get unbalanced; a codex-utils-template upgrade that changes the template grammar; renaming a placeholder without updating its paired key constant.","solutions":["Revert or fix the malformed syntax in codex-collaboration-mode-templates::DEFAULT until Template::parse succeeds -- the panic message embeds the parser error showing what failed.","Run the crate's existing preset tests (collaboration_mode_presets_tests.rs) which exercise parse+render of the default template before the panic can reach users.","If it appeared after a dependency bump, check codex-utils-template's changelog for grammar changes and migrate the template text."],"exampleFix":"// before: template edited with an unbalanced placeholder, parse fails at first use\n// const DEFAULT: &str = \"... {{KNOWN_MODE_NAMES ...\"; // never closed\n// after: well-formed placeholder, guarded by a render test\n// const DEFAULT: &str = \"... {{KNOWN_MODE_NAMES}} ...\";\n#[test]\nfn default_template_parses_and_renders() {\n    let template = Template::parse(COLLABORATION_MODE_DEFAULT).expect(\"must parse\");\n    template\n        .render([(KNOWN_MODE_NAMES_TEMPLATE_KEY, \"Plan and Default\")])\n        .expect(\"must render\");\n}","handlingStrategy":"validation","validationCode":"// CI guard: fail at test time, not at first user request\n#[test]\nfn default_template_parses_and_renders() {\n    let template = Template::parse(COLLABORATION_MODE_DEFAULT).expect(\"must parse\");\n    template\n        .render([(KNOWN_MODE_NAMES_TEMPLATE_KEY, \"Plan and Default\")])\n        .expect(\"must render\");\n}","typeGuard":null,"tryCatchPattern":"Not catchable as an io::Error: this is a panic inside a LazyLock. Only std::panic::catch_unwind at a thread boundary could intercept it; treat the message as a broken build invariant and fix the template instead of handling it.","preventionTips":["Run the models-manager preset tests after every edit to the DEFAULT/PLAN template constants.","Keep placeholder names in template text synchronized with the KNOWN_MODE_NAMES_TEMPLATE_KEY constant.","Never assemble the default template from runtime input; it is a static invariant by design."],"tags":["rust","codex","template","panic","lazy-init"],"backgroundTag":"template-parse-error","analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}