{"record":{"id":"b80609a4e017c1c3","repo":"BoundaryML/baml","slug":"default-role-must-be-one-of-system-user-or-assistant-please","errorCode":null,"errorMessage":"default_role must be one of 'system', 'user' or 'assistant': {}. Please specify \"allowed_roles\" if you want to use other custom default role.","messagePattern":"default_role must be one of 'system', 'user' or 'assistant': (.+?)\\. Please specify \"allowed_roles\" if you want to use other custom default role\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-lib/llm-client/src/clientspec.rs","lineNumber":370,"sourceCode":"            .transpose()?;\n\n        let remap: Option<HashMap<String, String>> = remap.map(|remap| {\n            remap\n                .into_iter()\n                .map(|(k, v)| (k.to_string(), v.to_string()))\n                .collect()\n        });\n\n        match (&allowed, &default) {\n            (Some(allowed), Some(default)) => {\n                if !allowed.contains(default) {\n                    return Err(anyhow::anyhow!(\"default_role must be in allowed_roles: {}. Not found in {:?}\", default, allowed));\n                }\n            }\n            (None, Some(default)) => {\n                match default.as_str() {\n                    \"system\" | \"user\" | \"assistant\" => {}\n                    _ => return Err(anyhow::anyhow!(\"default_role must be one of 'system', 'user' or 'assistant': {}. Please specify \\\"allowed_roles\\\" if you want to use other custom default role.\", default)),\n                }\n            }\n            _ => {}\n        }\n\n        match (&allowed, &remap) {\n            (Some(allowed), Some(remap)) => {\n                for k in remap.keys() {\n                    if !allowed.contains(k) {\n                        return Err(anyhow::anyhow!(\n                            \"remap_role must be in allowed_roles: {}. Not found in {:?}\",\n                            k,\n                            allowed\n                        ));\n                    }\n                }\n            }\n            (None, Some(remap)) => {","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-lib/llm-client/src/clientspec.rs#L352-L388","documentation":"When a BAML LLM client config specifies a `default_role` but no `allowed_roles`, only the built-in chat roles 'system', 'user', and 'assistant' are accepted. Any other default role string is rejected at client spec resolution time. To use a custom default role, you must explicitly list it in `allowed_roles`.","triggerScenarios":"Resolving a client spec where allowed_roles is unset and default_role is a string other than 'system', 'user', or 'assistant' (e.g. 'developer', 'function').","commonSituations":"Copying client configs from providers whose role vocabulary differs from OpenAI's (e.g. newer role names), or typos like 'System'/'users' in BAML client blocks.","solutions":["Change default_role to one of 'system', 'user', or 'assistant'.","Add an allowed_roles array that includes the custom default role you want.","Fix casing/typos in the default_role value (roles are matched exactly)."],"exampleFix":"// before\nclient<llm> MyClient {\n  provider openai\n  default_role \"developer\"\n}\n// after\nclient<llm> MyClient {\n  provider openai\n  default_role \"system\"\n}\n// or, to keep the custom role:\nclient<llm> MyClient {\n  provider openai\n  allowed_roles [\"system\", \"user\", \"assistant\", \"developer\"]\n  default_role \"developer\"\n}","handlingStrategy":"validation","validationCode":"const DEFAULT_ROLES = [\"system\", \"user\", \"assistant\"];\nif (!allowedRoles && defaultRole && !DEFAULT_ROLES.includes(defaultRole)) {\n  throw new Error(`default_role '${defaultRole}' requires allowed_roles`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep default_role within the standard three roles unless you also define allowed_roles.","Lint BAML client blocks for role values against the standard set."],"tags":["config","validation","roles","baml"],"backgroundTag":"invalid-enum-value","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}