BoundaryML/baml · error
remap_role must be in allowed_roles: {}. Not found in {:?}
Error message
remap_role must be in allowed_roles: {}. Not found in {:?} What it means
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.
Source
Thrown at engine/baml-lib/llm-client/src/clientspec.rs:380
(Some(allowed), Some(default)) => {
if !allowed.contains(default) {
return Err(anyhow::anyhow!("default_role must be in allowed_roles: {}. Not found in {:?}", default, allowed));
}
}
(None, Some(default)) => {
match default.as_str() {
"system" | "user" | "assistant" => {}
_ => 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)),
}
}
_ => {}
}
match (&allowed, &remap) {
(Some(allowed), Some(remap)) => {
for k in remap.keys() {
if !allowed.contains(k) {
return Err(anyhow::anyhow!(
"remap_role must be in allowed_roles: {}. Not found in {:?}",
k,
allowed
));
}
}
}
(None, Some(remap)) => {
let allowed = ["system", "user", "assistant"]
.iter()
.map(|s| s.to_string())
.collect::<Vec<_>>();
for k in remap.keys() {
if !allowed.contains(k) {
return Err(anyhow::anyhow!(
"remap_role must be in allowed_roles: {}. Not found in {:?}",
k,
allowedView on GitHub (pinned to bd85ce9dee)
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).
Example fix
// before
allowed_roles ["system", "user", "assistant"]
remap_roles { "developer" "system" }
// after
allowed_roles ["system", "user", "assistant", "developer"]
remap_roles { "developer" "system" } Defensive patterns
Strategy: validation
Validate before calling
for (const key of Object.keys(remapRoles)) {
if (!allowedRoles.includes(key)) {
throw new Error(`remap key '${key}' missing from allowed_roles`);
}
} Prevention
- Treat allowed_roles and remap_roles as one coupled unit; update both together.
- Derive remap keys from the allowed_roles list programmatically.
When it happens
Trigger: 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"].
Common situations: Editing allowed_roles to a narrower list and forgetting to prune remap_roles entries that referenced previously allowed roles.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- default_role must be one of 'system', 'user' or 'assistant':
- Invalid allowed role metadata: {}. Allowed values are 'all'
- script `{target}` has no `--function` and there is no implic
- test profile `{name}` was requested, but {} does not exist
- test profile `{name}` is not defined in {} (available: {avai
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/a25d246597c63742.
Report an issue: GitHub.