{"record":{"id":"c5f4c19c95f4badf","repo":"BoundaryML/baml","slug":"baml-fetch-as-expected-method-to-be-a-valid-http-method-got","errorCode":null,"errorMessage":"baml.fetch_as: expected method to be a valid HTTP method, got {}","messagePattern":"baml\\.fetch_as: expected method to be a valid HTTP method, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/async_vm_runtime.rs","lineNumber":613,"sourceCode":"                                    let response = 'res: {\n                                        let client = reqwest::Client::new();\n\n                                        let req = match &url_or_request {\n                                            BamlValue::String(url) => {\n                                                client.get(url)\n                                            }\n\n                                            // we type checked earlier, should be http request type\n                                            BamlValue::Class(name, fields) => {\n                                                let Some(BamlValue::String(url)) = fields.get(\"url\") else {\n                                                    break 'res Err(anyhow!(\n                                                        \"baml.fetch_as: expected url to be a string, got {}\",\n                                                        url_or_request\n                                                    ));\n                                                };\n\n                                                let Some(BamlValue::Enum(_, method)) = fields.get(\"method\") else {\n                                                    break 'res Err(anyhow!(\n                                                        \"baml.fetch_as: expected method to be a valid HTTP method, got {}\",\n                                                        url_or_request\n                                                    ));\n                                                };\n\n                                                let mut req = match method.as_str() {\n                                                    \"Get\" => client.get(url),\n                                                    \"Post\" => client.post(url),\n                                                    \"Put\" => client.put(url),\n                                                    \"Patch\" => client.patch(url),\n                                                    \"Delete\" => client.delete(url),\n                                                    _ => break 'res Err(anyhow!(\n                                                        \"baml.fetch_as: expected method to be a valid HTTP method, got {}\",\n                                                        method\n                                                    ))\n                                                };\n\n                                                if let Some(BamlValue::Map(headers)) = fields.get(\"headers\") {","sourceCodeStart":595,"sourceCodeEnd":631,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/async_vm_runtime.rs#L595-L631","documentation":"When reading a baml.HttpRequest, the `method` field must be an Enum value holding a valid HTTP method name. The field was missing or not an enum, so the runtime cannot determine the verb to use. (This branch fires when the field is absent or the wrong type; the message prints the whole request object.)","triggerScenarios":"Constructing baml.HttpRequest without a `method` field, or with a plain string/other value instead of an enum value for method.","commonSituations":"Passing method as a raw string like \"GET\" instead of the enum value, omitting method assuming a default (none exists), or building the request from JSON where method became a string.","solutions":["Set `method` on the baml.HttpRequest (e.g. method: \"Get\") — there is no default","Ensure method is supplied as the enum form the runtime expects, not a free-form string","Use one of the supported spellings: Get, Post, Put, Patch, Delete"],"exampleFix":"// before (BAML)\nlet req = baml.HttpRequest{url: \"https://api.example.com\"}\n// after\nlet req = baml.HttpRequest{url: \"https://api.example.com\", method: \"Get\"}","handlingStrategy":"validation","validationCode":"function validateMethod(req) {\n  if (req.method === undefined || req.method === null) {\n    throw new Error('baml.HttpRequest.method is required (Get|Post|Put|Patch|Delete)');\n  }\n}","typeGuard":"function hasMethod(req) { return typeof req === 'object' && req !== null && req.method != null; }","tryCatchPattern":"try {\n  const data = await runtime.callFunction(fnName, args);\n} catch (e) {\n  if (String(e).includes('expected method to be a valid HTTP method')) {\n    // add/fix the method field on the baml.HttpRequest and retry\n  } else throw e;\n}","preventionTips":["Never omit `method` — there is no default verb","Always set method when constructing baml.HttpRequest"],"tags":["baml","http","httprequest","method"],"backgroundTag":"invalid-enum-value","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}