{"record":{"id":"fcca2947a15958e8","repo":"BoundaryML/baml","slug":"execution-node-out-of-bounds-render-prompt-for-client","errorCode":null,"errorMessage":"Execution Node out of bounds (render prompt): {} >= {} for client {}","messagePattern":"Execution Node out of bounds \\(render prompt\\): (.+?) >= (.+?) for client (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/lib.rs","lineNumber":726,"sourceCode":"            function_params,\n            params,\n            internal_baml_core::ir::ArgCoercer {\n                span_path: None,\n                allow_implicit_cast_to_string: false,\n                skip_assert_eval: false,\n            },\n        )?;\n\n        let renderer = PromptRenderer::from_function(&func, self.ir(), ctx)?;\n\n        let client_spec = renderer.client_spec();\n        let client = self.get_llm_provider_impl(client_spec, ctx)?;\n        let mut selected =\n            client.iter_orchestrator(&mut Default::default(), Default::default(), ctx, self)?;\n        let node_index = node_index.unwrap_or(0);\n\n        if node_index >= selected.len() {\n            return Err(anyhow::anyhow!(\n                \"Execution Node out of bounds (render prompt): {} >= {} for client {}\",\n                node_index,\n                selected.len(),\n                client_spec,\n            ));\n        }\n\n        let baml_args =\n            BamlValue::Map(baml_args.into_iter().map(|(k, v)| (k, v.value())).collect());\n        let node = selected.swap_remove(node_index);\n        node.provider\n            .render_prompt(self.ir(), &renderer, ctx, &baml_args)\n            .await\n            .map(|prompt| (prompt, node.scope, node.provider.allowed_metadata().clone()))\n    }\n\n    pub fn llm_provider_from_function(\n        &self,","sourceCodeStart":708,"sourceCodeEnd":744,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/lib.rs#L708-L744","documentation":"render_prompt_impl resolves the client's orchestrator strategy into a list of execution nodes, then indexes into that list with node_index. When the requested node index equals or exceeds the number of selected nodes, rendering cannot pick a prompt and the runtime errors out naming the index, list length, and client spec.","triggerScenarios":"Calling render_prompt with Some(node_index) that is beyond the orchestrator's selected node count — e.g. requesting node 2 of a fallback/orchestra chain that only resolved to 1 node, or a single client producing just one node while a larger index is passed.","commonSituations":"Retrying/stepping through fallback chains with stale node indices; clients whose retry/fallback policy changed so fewer nodes exist than the caller expects; hardcoded indices in custom orchestration code.","solutions":["Pass None (or 0) for node_index to use the first/default execution node","Clamp node_index to selected.len() - 1, or inspect the client's strategy to know how many nodes exist","Update client retry/fallback config so it defines as many nodes as your code requests","Fix callers (e.g. render_prompt wrappers) that pass a stale index from a previous client configuration"],"exampleFix":"// before\nrt.render_prompt(&ctx, &client, &fn_name, &args, Some(2))?; // only 1 node\n// after\nrt.render_prompt(&ctx, &client, &fn_name, &args, None)?;","handlingStrategy":"validation","validationCode":"if let Some(idx) = node_index {\n    if idx >= num_execution_nodes(client) {\n        return Err(format!(\"node_index {} out of range for client\", idx));\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default to node_index = None unless you know the orchestrator shape","Keep retry/fallback client config in sync with any hardcoded node indices","Clamp requested indices to the number of selected nodes"],"tags":["rust","orchestration","index","prompt"],"backgroundTag":"index-out-of-bounds","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"}