{"record":{"id":"8a18e191c133b7e5","repo":"kestra-io/kestra","slug":"the-http-function-expects-an-argument-uri","errorCode":null,"errorMessage":"The 'http' function expects an argument 'uri'.","messagePattern":"The 'http' function expects an argument 'uri'\\.","errorType":"validation","errorClass":"PebbleException","httpStatus":null,"severity":"critical","filePath":"core/src/main/java/io/kestra/core/runners/pebble/functions/HttpFunction.java","lineNumber":143,"sourceCode":"    private HttpRequest.RequestBody toRequestBody(Map<String, Object> args, PebbleTemplate self, int lineNumber, String contentType) {\n        HttpRequest.RequestBody body;\n        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();\n        Class<T> bodyClass = (Class<T>) args.get(\"body\").getClass();\n        MessageBodyWriter<T> bodyWriter = defaultMessageBodyHandlerRegistry.findWriter(Argument.of(bodyClass), MediaType.of(contentType)).orElse(FALLBACK_CONTENT_WRITER);\n        bodyWriter.writeTo(Argument.of(bodyClass), MediaType.of(contentType), (T) args.get(\"body\"), new SimpleHttpHeaders(), byteArrayOutputStream);\n        try {\n            body = HttpRequest.RequestBody.from(\n                new ByteArrayEntity(byteArrayOutputStream.toByteArray(), ContentType.create(contentType))\n            );\n        } catch (IOException e) {\n            throw new PebbleException(e, \"Couldn't parse the request body\", lineNumber, self.getName());\n        }\n        return body;\n    }\n\n    private void throwIfMissingArgs(Map<String, Object> args, PebbleTemplate self, int lineNumber) {\n        if (!args.containsKey(\"uri\")) {\n            throw new PebbleException(null, \"The 'http' function expects an argument 'uri'.\", lineNumber, self.getName());\n        }\n    }\n\n    @Override\n    public List<String> getArgumentNames() {\n        return List.of(\"uri\", \"method\", \"query\", \"body\", \"contentType\", \"headers\", \"options\", \"accept\");\n    }\n\n    @Override\n    public Map<String, String> getArgumentDefaults() {\n        HashMap<String, String> defaults = new HashMap<>();\n        defaults.put(\"uri\", \"'https://example.com'\");\n        defaults.put(\"method\", \"'GET'\");\n        defaults.put(\"query\", null);\n        defaults.put(\"body\", null);\n        defaults.put(\"contentType\", null);\n        defaults.put(\"headers\", null);\n        defaults.put(\"options\", null);","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/functions/HttpFunction.java#L125-L161","documentation":"The 'http' Pebble function requires a 'uri' argument; this is thrown up-front by throwIfMissingArgs when uri is not present in the call.","triggerScenarios":"Calling http() with no arguments, or only named arguments that omit uri (e.g. http(method='GET')).","commonSituations":"Forgot the uri, or referenced a variable for uri that resolved to null so the key was never set.","solutions":["Pass a uri argument, e.g. http('https://example.com') or http(uri=...).","If uri is templated, ensure the expression resolves to a non-null string or URI before the call."],"exampleFix":"// before\n{{ http(method='GET') }}\n// after\n{{ http('https://example.com', method='GET') }}","handlingStrategy":"validation","validationCode":"{% if myUri is not empty %}{{ http(myUri) }}{% endif %}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass uri as the first positional argument or as an explicit named arg.","Guard templated uris with 'is not empty' before calling.","Treat a missing uri as a template bug and fix it at the source."],"tags":["pebble","http","argument","required-arg"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}