prestodb/presto · error · PrestoException

GENERIC_INTERNAL_ERROR

GENERIC_INTERNAL_ERROR

Error message

Metadata sidecar returned HTTP %d for %s

What it means

DriverSidecarFunctionRegistryTool.fetchFromSidecar performs a synchronous OkHttp GET to the metadata sidecar's function-signatures endpoint. If the HTTP response is not successful (non-2xx), it throws PrestoException(GENERIC_INTERNAL_ERROR) with the status code and endpoint, because UDF metadata could not be retrieved and worker function registration cannot proceed.

Source

Thrown at presto-spark-base/src/main/java/com/facebook/presto/spark/execution/nativeprocess/DriverSidecarFunctionRegistryTool.java:114

    private synchronized UdfFunctionSignatureMap getCachedSignatureMap()
    {
        if (cachedSignatureMap == null) {
            cachedSignatureMap = fetchFromSidecar();
        }
        return cachedSignatureMap;
    }

    private UdfFunctionSignatureMap fetchFromSidecar()
    {
        URI sidecarUri = sidecarProcessFactory.getOrStart();
        try {
            URI endpoint = sidecarUri.resolve(FUNCTION_SIGNATURES_ENDPOINT);
            Request request = new Request.Builder().url(endpoint.toString()).get().build();
            log.info("Fetching native function metadata from %s", endpoint);

            try (Response response = httpClient.newCall(request).execute()) {
                if (!response.isSuccessful()) {
                    throw new PrestoException(
                            GENERIC_INTERNAL_ERROR,
                            String.format("Metadata sidecar returned HTTP %d for %s", response.code(), endpoint));
                }
                ResponseBody body = response.body();
                if (body == null) {
                    throw new PrestoException(
                            GENERIC_INTERNAL_ERROR,
                            String.format("Metadata sidecar returned an empty body for %s", endpoint));
                }
                String responseJson = body.string();
                Map<String, List<JsonBasedUdfFunctionMetadata>> map =
                        functionSignatureMapJsonCodec.fromJson(responseJson);
                log.info("Fetched %d native function names from metadata sidecar", map.size());
                return new UdfFunctionSignatureMap(ImmutableMap.copyOf(map));
            }
            catch (IOException e) {
                throw new PrestoException(
                        GENERIC_INTERNAL_ERROR,

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Read the HTTP status code in the message and check the sidecar's logs for the corresponding server-side error.
  2. Verify the sidecar's FUNCTION_SIGNATURES_ENDPOINT path matches the sidecar binary's actual API route (version alignment).
  3. Confirm the sidecar process is healthy by hitting the endpoint manually with curl from the driver host.
  4. Ensure the sidecar was launched with correct metadata/function-manifest inputs so it can serve signatures.

Example fix

// before: immediate fatal throw on non-2xx
if (!response.isSuccessful()) {
    throw new PrestoException(GENERIC_INTERNAL_ERROR,
            String.format("Metadata sidecar returned HTTP %d for %s", response.code(), endpoint));
}
// after: bounded retry for transient 5xx
if (!response.isSuccessful() && response.code() >= 500) {
    if (retryAttempt < MAX_RETRIES) {
        return fetchFromSidecarWithRetry(retryAttempt + 1);
    }
}
throw new PrestoException(GENERIC_INTERNAL_ERROR,
        String.format("Metadata sidecar returned HTTP %d for %s", response.code(), endpoint));
Defensive patterns

Strategy: retry

Validate before calling

// pre-flight: verify the sidecar endpoint is healthy before registering functions
try (Response r = httpClient.newCall(new Request.Builder()
        .url(sidecarUri.resolve("/v1/function-signatures").toString()).get().build()).execute()) {
    if (!r.isSuccessful()) {
        throw new IllegalStateException("Sidecar unhealthy, HTTP " + r.code());
    }
}

Try / catch

try {
    List<? extends SqlFunction> fns = registryTool.getWorkerFunctions();
} catch (PrestoException e) {
    if (e.getMessage() != null && e.getMessage().startsWith("Metadata sidecar returned HTTP")) {
        // parse status from message; retry only for 5xx, fail fast for 4xx
        log.error("Sidecar metadata fetch failed: %s", e.getMessage());
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling getWorkerFunctions/getRpcFunctionNames (which triggers getCachedSignatureMap -> fetchFromSidecar) when the sidecar HTTP GET for FUNCTION_SIGNATURES_ENDPOINT returns a non-2xx status (404, 500, 503...).

Common situations: Sidecar process started but serving a wrong endpoint path (version mismatch between driver tool and sidecar); sidecar failed to load its function metadata at startup; sidecar port conflict or proxy intercepting the request and returning an error page.

Related errors


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