{"record":{"id":"dfed35dde6b00d3a","repo":"prestodb/presto","slug":"invalid-arguments-dfed35","errorCode":"INVALID_ARGUMENTS","errorMessage":"Invalid functionId !","messagePattern":"Invalid functionId !","errorType":"error_code","errorClass":"PrestoException","httpStatus":400,"severity":"warning","filePath":"presto-function-server/src/main/java/com/facebook/presto/server/FunctionResource.java","lineNumber":272,"sourceCode":"            pageBuilder.declarePosition();\n            BlockBuilder output = pageBuilder.getBlockBuilder(0);\n            createResultBlock(output, returnType, result);\n        }\n\n        Page outputPage = pageBuilder.build();\n        DynamicSliceOutput sliceOutput = new DynamicSliceOutput((int) outputPage.getRetainedSizeInBytes());\n        writeSerializedPage(sliceOutput, pagesSerde.serialize(outputPage));\n        return sliceOutput.slice().byteArray();\n    }\n\n    public static List<TypeSignatureProvider> extractArgumentTypeSignatures(String encodedFunctionId)\n    {\n        String functionId;\n        try {\n            functionId = URLDecoder.decode(encodedFunctionId, StandardCharsets.UTF_8.toString());\n        }\n        catch (UnsupportedEncodingException e) {\n            throw new PrestoException(INVALID_ARGUMENTS, \"Invalid functionId !\");\n        }\n\n        SqlFunctionId sqlFunctionId = SqlFunctionId.parseSqlFunctionId(functionId);\n        return sqlFunctionId.getArgumentTypes().stream()\n                .map(TypeSignatureProvider::new)\n                .collect(Collectors.toList());\n    }\n\n    private Object deserializeBlock(Type type, Block block)\n    {\n        if (block.isNull(0)) {\n            return null;\n        }\n\n        switch (type.getTypeSignature().getBase()) {\n            case \"boolean\":\n                return block.getByte(0) != 0;\n            case \"integer\":","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-function-server/src/main/java/com/facebook/presto/server/FunctionResource.java#L254-L290","documentation":"FunctionResource.extractArgumentTypeSignatures URL-decodes the encoded function id from the HTTP request; if URLDecoder.decode fails (UnsupportedEncodingException for a bad charset) it throws INVALID_ARGUMENTS with 'Invalid functionId !'. This guards the REST function-lookup endpoint against malformed function id parameters.","triggerScenarios":"GET on the function resource endpoint with an encodedFunctionId that fails URL decoding; practically, a request whose functionId parameter is malformed or corrupted by double/incorrect encoding before reaching the resource.","commonSituations":"Hand-constructing the REST URL without properly percent-encoding the function id; client frameworks double-encoding special characters; copied URLs with truncated or mangled query parameters.","solutions":["URL-encode the function id (e.g. using java.net.URLEncoder or encodeURIComponent) when building the request URL.","Do not pre-decode the functionId before sending; send the encoded form once.","Inspect the request parameter for stray characters (%, non-UTF8 bytes) and rebuild the URL."],"exampleFix":"// before\nString url = \"/v1/function/state/catalog/schema/abs(varchar)\"; // unencoded\n// after\nString url = \"/v1/function/state/catalog/schema/\" + URLEncoder.encode(functionId, StandardCharsets.UTF_8);","handlingStrategy":"validation","validationCode":"// Client side: always encode before sending\nString encoded = URLEncoder.encode(functionId, StandardCharsets.UTF_8);\nHttpRequest req = HttpRequest.newBuilder(URI.create(base + \"/v1/function/state/catalog/schema/\" + encoded)).build();","typeGuard":"boolean isSafeFunctionIdParam(String encodedFunctionId) {\n    try {\n        URLDecoder.decode(encodedFunctionId, StandardCharsets.UTF_8);\n        return true;\n    } catch (IllegalArgumentException | UnsupportedEncodingException e) {\n        return false;\n    }\n}","tryCatchPattern":"try {\n    List<TypeSignature> types = resource.argumentTypeSignatures(encodedFunctionId);\n} catch (PrestoException e) {\n    if (e.getErrorCode().equals(INVALID_ARGUMENTS.toErrorCode())) {\n        // respond 400 with guidance to re-encode the functionId\n    }\n}","preventionTips":["Use URLEncoder/encodeURIComponent for the functionId path segment.","Never double-encode or pre-decode the parameter client-side.","Validate URLs contain only ASCII and properly escaped '%' sequences.","Add integration tests that hit the REST endpoint with special characters in ids."],"tags":["http","url-encoding","rest-api","invalid-arguments"],"backgroundTag":"malformed-request-parameter","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}