{"record":{"id":"02aa09b8e86bb23a","repo":"BoundaryML/baml","slug":"could-not-find-retry-policy-with-name","errorCode":null,"errorMessage":"Could not find retry policy with name: {}","messagePattern":"Could not find retry policy with name: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/lib.rs","lineNumber":1992,"sourceCode":"        }\n    }\n\n    pub(crate) fn get_retry_policy_impl(\n        &self,\n        policy_name: &str,\n        _ctx: &RuntimeContext,\n    ) -> Result<CallablePolicy> {\n        #[cfg(target_arch = \"wasm32\")]\n        let mut retry_policies = self.retry_policies.lock().unwrap();\n        #[cfg(not(target_arch = \"wasm32\"))]\n        let retry_policies = &self.retry_policies;\n\n        let inserter = || {\n            self.ir()\n                .walk_retry_policies()\n                .find(|walker| walker.name() == policy_name)\n                .ok_or_else(|| {\n                    anyhow::anyhow!(\"Could not find retry policy with name: {}\", policy_name)\n                })\n                .map(CallablePolicy::from)\n        };\n\n        #[cfg(target_arch = \"wasm32\")]\n        {\n            if let Some(policy_ref) = retry_policies.get(policy_name) {\n                return Ok(policy_ref.clone());\n            }\n            let new_policy = inserter()?;\n            retry_policies.insert(policy_name.into(), new_policy.clone());\n            Ok(new_policy)\n        }\n\n        #[cfg(not(target_arch = \"wasm32\"))]\n        {\n            let policy_ref = retry_policies\n                .entry(policy_name.into())","sourceCodeStart":1974,"sourceCodeEnd":2010,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/lib.rs#L1974-L2010","documentation":"BAML looks up a retry policy by name in the compiled IR when resolving a client's retry configuration. If no retry policy with the given name exists in any loaded BAML source file, the lookup fails with this error. This is a name-resolution failure: the policy referenced by the client (or requested by the caller) was never declared in the .baml files.","triggerScenarios":"Calling get_retry_policy / the policy lookup inserter with a policy_name that doesn't match any `retry_policy <Name> { ... }` block in the loaded BAML sources (e.g. a client config referencing `retry_policy MissingPolicy`).","commonSituations":"Typo in the retry policy name in a client block; renaming/deleting a retry_policy in the .baml files without updating clients; loading the wrong baml_src directory that doesn't contain the file defining the policy.","solutions":["Check the retry policy name for typos against the `retry_policy` blocks in your .baml files","Define the missing `retry_policy <Name> { ... }` block in your BAML sources","If the client references a policy, update its `retry_policy` field to an existing policy name","Verify you're loading the correct baml_src directory containing the file with the policy"],"exampleFix":"// before\nclient GPT4 {\n  provider openai\n  retry_policy ProdRetrey // typo\n}\n\n// after\nclient GPT4 {\n  provider openai\n  retry_policy ProdRetry\n}\n\nretry_policy ProdRetry {\n  max_retries 3\n}","handlingStrategy":"validation","validationCode":"import { parse } from '@baml-lang/core';\nconst policyNames = new Set([...src.matchAll(/retry_policy\\s+(\\w+)/g)].map((m) => m[1]));\nif (!policyNames.has('ProdRetry')) throw new Error('retry_policy ProdRetry is not defined in .baml sources');","typeGuard":null,"tryCatchPattern":"try {\n  const policy = runtime.getRetryPolicy('ProdRetry');\n} catch (e) {\n  if (/Could not find retry policy/i.test(e.message)) {\n    console.error('Declare retry_policy ProdRetry { ... } in your .baml files or fix the name');\n  }\n  throw e;\n}","preventionTips":["Define all retry policies in one shared .baml file and reference by exact name","Grep your .baml sources for retry_policy names when renaming/deleting one","Run `baml-cli dev` so diagnostics surface unknown references before runtime","Keep clients and their retry policies in the same loaded baml_src"],"tags":["baml","configuration","retry","not-found"],"backgroundTag":"resource-not-found","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"}