{"record":{"id":"d17de40cefbce3bc","repo":"sigoden/aichat","slug":"unable-to-save-the-role-with-arguments-whose-name","errorCode":null,"errorMessage":"Unable to save the role with arguments (whose name contains '#')","messagePattern":"Unable to save the role with arguments \\(whose name contains '#'\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/config/mod.rs","lineNumber":999,"sourceCode":"        self.use_role(&name)\n    }\n\n    pub fn upsert_role(&mut self, name: &str) -> Result<()> {\n        let role_path = Self::role_file(name);\n        ensure_parent_exists(&role_path)?;\n        let editor = self.editor()?;\n        edit_file(&editor, &role_path)?;\n        if self.working_mode.is_repl() {\n            println!(\"✓ Saved the role to '{}'.\", role_path.display());\n        }\n        Ok(())\n    }\n\n    pub fn save_role(&mut self, name: Option<&str>) -> Result<()> {\n        let mut role_name = match &self.role {\n            Some(role) => {\n                if role.has_args() {\n                    bail!(\"Unable to save the role with arguments (whose name contains '#')\")\n                }\n                match name {\n                    Some(v) => v.to_string(),\n                    None => role.name().to_string(),\n                }\n            }\n            None => bail!(\"No role\"),\n        };\n        if role_name == TEMP_ROLE_NAME {\n            role_name = Text::new(\"Role name:\")\n                .with_validator(|input: &str| {\n                    let input = input.trim();\n                    if input.is_empty() {\n                        Ok(Validation::Invalid(\"This name is required\".into()))\n                    } else if input == TEMP_ROLE_NAME {\n                        Ok(Validation::Invalid(\"This name is reserved\".into()))\n                    } else {\n                        Ok(Validation::Valid)","sourceCodeStart":981,"sourceCodeEnd":1017,"githubUrl":"https://github.com/sigoden/aichat/blob/82976d349ad97ac9aae0655ad631dace5e2a6385/src/config/mod.rs#L981-L1017","documentation":"Raised by save_role() when the current role uses argument placeholders (its name/prompt contains '#' argument markers). Such roles are ephemeral by design; persisting a role with unresolved arguments would bake in invalid placeholders, so saving is refused. The input at fault is a role with has_args() true.","triggerScenarios":"Thrown at src/config/mod.rs:999 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the argument placeholders from the prompt before saving","Save the role under a plain name without arguments and pass arguments at usage time","Use upsert_role with an explicit, argument-free definition instead"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"82976d349ad97ac9aae0655ad631dace5e2a6385","analyzedAt":"2026-09-09T18:33:06.139Z","contentChangedAt":"2026-09-09T18:33:06.139Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}