prestodb/presto · warning · PrestoException

INVALID_ARGUMENTS

INVALID_ARGUMENTS

Error message

Invalid functionId !

What it means

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.

Source

Thrown at presto-function-server/src/main/java/com/facebook/presto/server/FunctionResource.java:272

            pageBuilder.declarePosition();
            BlockBuilder output = pageBuilder.getBlockBuilder(0);
            createResultBlock(output, returnType, result);
        }

        Page outputPage = pageBuilder.build();
        DynamicSliceOutput sliceOutput = new DynamicSliceOutput((int) outputPage.getRetainedSizeInBytes());
        writeSerializedPage(sliceOutput, pagesSerde.serialize(outputPage));
        return sliceOutput.slice().byteArray();
    }

    public static List<TypeSignatureProvider> extractArgumentTypeSignatures(String encodedFunctionId)
    {
        String functionId;
        try {
            functionId = URLDecoder.decode(encodedFunctionId, StandardCharsets.UTF_8.toString());
        }
        catch (UnsupportedEncodingException e) {
            throw new PrestoException(INVALID_ARGUMENTS, "Invalid functionId !");
        }

        SqlFunctionId sqlFunctionId = SqlFunctionId.parseSqlFunctionId(functionId);
        return sqlFunctionId.getArgumentTypes().stream()
                .map(TypeSignatureProvider::new)
                .collect(Collectors.toList());
    }

    private Object deserializeBlock(Type type, Block block)
    {
        if (block.isNull(0)) {
            return null;
        }

        switch (type.getTypeSignature().getBase()) {
            case "boolean":
                return block.getByte(0) != 0;
            case "integer":

View on GitHub (pinned to 55bb57d202)

Solutions

  1. URL-encode the function id (e.g. using java.net.URLEncoder or encodeURIComponent) when building the request URL.
  2. Do not pre-decode the functionId before sending; send the encoded form once.
  3. Inspect the request parameter for stray characters (%, non-UTF8 bytes) and rebuild the URL.

Example fix

// before
String url = "/v1/function/state/catalog/schema/abs(varchar)"; // unencoded
// after
String url = "/v1/function/state/catalog/schema/" + URLEncoder.encode(functionId, StandardCharsets.UTF_8);
Defensive patterns

Strategy: validation

Validate before calling

// Client side: always encode before sending
String encoded = URLEncoder.encode(functionId, StandardCharsets.UTF_8);
HttpRequest req = HttpRequest.newBuilder(URI.create(base + "/v1/function/state/catalog/schema/" + encoded)).build();

Type guard

boolean isSafeFunctionIdParam(String encodedFunctionId) {
    try {
        URLDecoder.decode(encodedFunctionId, StandardCharsets.UTF_8);
        return true;
    } catch (IllegalArgumentException | UnsupportedEncodingException e) {
        return false;
    }
}

Try / catch

try {
    List<TypeSignature> types = resource.argumentTypeSignatures(encodedFunctionId);
} catch (PrestoException e) {
    if (e.getErrorCode().equals(INVALID_ARGUMENTS.toErrorCode())) {
        // respond 400 with guidance to re-encode the functionId
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/dfed35dde6b00d3a. Report an issue: GitHub.