BoundaryML/baml · error
Unexpected postfix operator: {:?}
Error message
Unexpected postfix operator: {:?} What it means
This is a `unreachable!()` panic from the fallback arm of `parse_config_map_key` in the BAML AST parser. The function iterates the children of a `config_map_key` pair, and after the loop it asserts that the key was definitely captured; reaching the trailing `unreachable!()` means every child rule fell through without assigning the key expression — a broken grammar/parser contract. Note the arm just above calls `unreachable_rule` (which reports a diagnostic and returns a placeholder), so this line should be impossible even on malformed input.
Source
Thrown at engine/baml-lib/ast/src/parser/parse_expression.rs:130
Rule::generic_fn_app => match parse_generic_fn_app(inner, diagnostics)? {
Expression::App(fn_call) => Expression::MethodCall {
receiver: Box::new(left),
method: fn_call.name,
args: fn_call.args,
type_args: fn_call.type_args,
span: span.clone(),
},
_ => {
unreachable!("expected function call when parsing method call")
}
},
_ => unreachable!("Unexpected method call rule: {:?}", inner.as_rule()),
}
}
_ => unreachable!("Unexpected postfix operator: {:?}", operator.as_rule()),
})
})
.map_infix(|left, operator, right| {
let operator = match operator.as_rule() {
Rule::EQ => BinaryOperator::Eq,
Rule::NEQ => BinaryOperator::Neq,
Rule::LT => BinaryOperator::Lt,
Rule::LTEQ => BinaryOperator::LtEq,
Rule::GT => BinaryOperator::Gt,
Rule::GTEQ => BinaryOperator::GtEq,
Rule::ADD => BinaryOperator::Add,
Rule::SUB => BinaryOperator::Sub,
Rule::MUL => BinaryOperator::Mul,
Rule::DIV => BinaryOperator::Div,
Rule::MOD => BinaryOperator::Mod,
Rule::BIT_AND => BinaryOperator::BitAnd,
Rule::BIT_OR => BinaryOperator::BitOr,
Rule::BIT_XOR => BinaryOperator::BitXor,View on GitHub (pinned to bd85ce9dee)
Solutions
- Use a plain identifier as the config map key (e.g. `provider "openai"` style with simple names), not quoted/complex keys
- Inspect the config entry at the panic span and rewrite the key in standard BAML config syntax
- If you are a contributor: extend `parse_config_map_key`'s loop to cover all rules allowed for `config_map_key` in baml.pest
- Upgrade BAML so the config key grammar and parser agree
Example fix
// before (unusual key form)
client MyClient {
"api key setting" "value"
}
// after
client MyClient {
api_key_setting "value"
} Defensive patterns
Strategy: validation
Validate before calling
// Ensure config map keys are plain identifiers before writing BAML config:
function assertPlainConfigKey(entry) {
if (!/^[A-Za-z_]\w*$/.test(entry.key)) {
throw new Error(`Config map key '${entry.key}' is not a plain identifier; the BAML parser may panic`);
}
} Type guard
const isPlainIdentifierKey = (key) => typeof key === 'string' && /^[A-Za-z_]\w*$/.test(key);
Try / catch
catch (panicOutput) {
if (String(panicOutput).includes('Encountered impossible config map key')) {
logParserBug('config_map_key produced no recognized child rule', panicOutput);
return null;
}
throw panicOutput;
} Prevention
- Use simple identifier keys in client/llm/retriever config blocks
- Extend parse_config_map_key whenever config_map_key grammar rules change
- Fuzz config-block parsing when touching baml.pest config rules
- Pin grammar and parser to the same release
When it happens
Trigger: Parsing a config map entry (e.g. inside a BAML client/llm config block) whose `config_map_key` pair contains only rules not matched by the loop's arms — e.g. after a grammar change renaming the key rules (`identifier`, `string_literal`) without updating `parse_config_map_key`.
Common situations: Writing config blocks with unusual keys (quoted or computed keys) in a BAML version where the key grammar changed; contributors editing baml.pest config-map rules without updating the key parser.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Name should always be defined for attribute.
- Encountered impossible doc comment during parsing: {:?}, {:?
- c_for_init_stmt cannot accept empty input
- c_for_after_stmt cannot accept empty input
- block aware tail expression is not empty
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/7b30964668357d2d.
Report an issue: GitHub.