{"record":{"id":"a25d246597c63742","repo":"BoundaryML/baml","slug":"remap-role-must-be-in-allowed-roles-not-found-in","errorCode":null,"errorMessage":"remap_role must be in allowed_roles: {}. Not found in {:?}","messagePattern":"remap_role must be in allowed_roles: (.+?)\\. Not found in (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-lib/llm-client/src/clientspec.rs","lineNumber":380,"sourceCode":"            (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)) => {\n                let allowed = [\"system\", \"user\", \"assistant\"]\n                    .iter()\n                    .map(|s| s.to_string())\n                    .collect::<Vec<_>>();\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","sourceCodeStart":362,"sourceCodeEnd":398,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-lib/llm-client/src/clientspec.rs#L362-L398","documentation":"When both `allowed_roles` and `remap_roles` are set, every key in `remap_roles` must be a member of `allowed_roles`. Resolution fails if a remap source role is not in the allowed set, since remapping a disallowed role is meaningless.","triggerScenarios":"Client spec resolve where allowed_roles=[...] and remap_roles contains a key not present in allowed_roles, e.g. remap_roles { \"developer\" \"system\" } with allowed_roles [\"system\",\"user\",\"assistant\"].","commonSituations":"Editing allowed_roles to a narrower list and forgetting to prune remap_roles entries that referenced previously allowed roles.","solutions":["Add the remap key to allowed_roles.","Remove the remap entry whose key is not in allowed_roles.","Align remap_roles keys with the exact strings in allowed_roles (case-sensitive)."],"exampleFix":"// before\nallowed_roles [\"system\", \"user\", \"assistant\"]\nremap_roles { \"developer\" \"system\" }\n// after\nallowed_roles [\"system\", \"user\", \"assistant\", \"developer\"]\nremap_roles { \"developer\" \"system\" }","handlingStrategy":"validation","validationCode":"for (const key of Object.keys(remapRoles)) {\n  if (!allowedRoles.includes(key)) {\n    throw new Error(`remap key '${key}' missing from allowed_roles`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat allowed_roles and remap_roles as one coupled unit; update both together.","Derive remap keys from the allowed_roles list programmatically."],"tags":["config","validation","roles","baml"],"backgroundTag":"invalid-config-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"}