{"record":{"id":"0dfa7ed16ecad678","repo":"BoundaryML/baml","slug":"builtin-function-baml-fetch-value-is-not-supported-in","errorCode":null,"errorMessage":"builtin function baml.fetch_value is not supported in interpreter at {:?}","messagePattern":"builtin function baml\\.fetch_value is not supported in interpreter at (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-compiler/src/thir/interpret.rs","lineNumber":2125,"sourceCode":"                                    meta.0\n                                ),\n                            }\n                        }\n                    }\n                }\n\n                EvalValue::Value(BamlValueWithMeta::Class(\n                    name.clone(),\n                    field_map,\n                    meta.clone(),\n                ))\n            }\n            Expr::Builtin(builtin, meta) => {\n                use crate::thir::Builtin;\n                match builtin {\n                    Builtin::FetchValue => {\n                        // FetchValue requires network access and is not supported in the interpreter\n                        bail!(\n                            \"builtin function baml.fetch_value is not supported in interpreter at {:?}\",\n                            meta.0\n                        )\n                    }\n                }\n            }\n            Expr::BinaryOperation {\n                left,\n                operator,\n                right,\n                meta,\n            } => {\n                // Special handling for instanceof: right operand is a type name, not a value\n                if matches!(operator, crate::hir::BinaryOperator::InstanceOf) {\n                    let left_val = expect_value(\n                        evaluate_expr(\n                            left,\n                            scopes,","sourceCodeStart":2107,"sourceCodeEnd":2143,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-compiler/src/thir/interpret.rs#L2107-L2143","documentation":"The builtin `baml.fetch_value` requires network/runtime value-store access, which the THIR interpreter does not implement. Encountering Builtin::FetchValue during expression evaluation unconditionally raises \"builtin function baml.fetch_value is not supported in interpreter\". It is a deliberate capability gap, not a bug in your expression.","triggerScenarios":"Any interpreted evaluation (interpreter-based tests, runtime expression evaluation) that executes code containing a baml.fetch_value call.","commonSituations":"Using fetch_value to read runtime-provided values (secrets, dynamic config) inside a function that is then run through the interpreter; migrating code compiled to the normal runtime into an interpreter-based path.","solutions":["Refactor to pass the value as a function argument instead of calling baml.fetch_value inside interpreted code","Resolve the value outside the interpreted expression and inject it via the environment/context","Run the function through the normal compiled/runtime execution path instead of the interpreter","Track BAML releases for interpreter support of fetch_value and upgrade when available"],"exampleFix":"// before\nfn f() { baml.fetch_value(\"API_KEY\") }\n// after\nfn f(api_key: string) { api_key } // caller resolves fetch_value and passes it in","handlingStrategy":"fallback","validationCode":"// Detect fetch_value usage before sending code to the interpreter\nfunction usesFetchValue(code: string): boolean {\n  return code.includes(\"baml.fetch_value\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  return interpreter.run(code, env);\n} catch (e) {\n  if (String(e).includes(\"baml.fetch_value is not supported\")) {\n    return runViaCompiledRuntime(code, env); // fallback to full runtime\n  }\n  throw e;\n}","preventionTips":["Pass externally-fetched values as function parameters instead of calling fetch_value inside interpreted code","Resolve dynamic config/secrets in the host language and inject them via the environment","Keep fetch_value in functions executed on the compiled runtime path only","Add a lint/grep gate that flags baml.fetch_value in interpreter-targeted code"],"tags":["interpreter","builtin","unsupported"],"backgroundTag":"operation-not-supported","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}