{"record":{"id":"4a17c47803fb2e32","repo":"prestodb/presto","slug":"generic-internal-error-4a17c4","errorCode":"GENERIC_INTERNAL_ERROR","errorMessage":"Metadata sidecar returned HTTP %d for %s","messagePattern":"Metadata sidecar returned HTTP (.+?) for (.+?)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-spark-base/src/main/java/com/facebook/presto/spark/execution/nativeprocess/DriverSidecarFunctionRegistryTool.java","lineNumber":114,"sourceCode":"    private synchronized UdfFunctionSignatureMap getCachedSignatureMap()\n    {\n        if (cachedSignatureMap == null) {\n            cachedSignatureMap = fetchFromSidecar();\n        }\n        return cachedSignatureMap;\n    }\n\n    private UdfFunctionSignatureMap fetchFromSidecar()\n    {\n        URI sidecarUri = sidecarProcessFactory.getOrStart();\n        try {\n            URI endpoint = sidecarUri.resolve(FUNCTION_SIGNATURES_ENDPOINT);\n            Request request = new Request.Builder().url(endpoint.toString()).get().build();\n            log.info(\"Fetching native function metadata from %s\", endpoint);\n\n            try (Response response = httpClient.newCall(request).execute()) {\n                if (!response.isSuccessful()) {\n                    throw new PrestoException(\n                            GENERIC_INTERNAL_ERROR,\n                            String.format(\"Metadata sidecar returned HTTP %d for %s\", response.code(), endpoint));\n                }\n                ResponseBody body = response.body();\n                if (body == null) {\n                    throw new PrestoException(\n                            GENERIC_INTERNAL_ERROR,\n                            String.format(\"Metadata sidecar returned an empty body for %s\", endpoint));\n                }\n                String responseJson = body.string();\n                Map<String, List<JsonBasedUdfFunctionMetadata>> map =\n                        functionSignatureMapJsonCodec.fromJson(responseJson);\n                log.info(\"Fetched %d native function names from metadata sidecar\", map.size());\n                return new UdfFunctionSignatureMap(ImmutableMap.copyOf(map));\n            }\n            catch (IOException e) {\n                throw new PrestoException(\n                        GENERIC_INTERNAL_ERROR,","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-spark-base/src/main/java/com/facebook/presto/spark/execution/nativeprocess/DriverSidecarFunctionRegistryTool.java#L96-L132","documentation":"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.","triggerScenarios":"Calling getWorkerFunctions/getRpcFunctionNames (which triggers getCachedSignatureMap -> fetchFromSidecar) when the sidecar HTTP GET for FUNCTION_SIGNATURES_ENDPOINT returns a non-2xx status (404, 500, 503...).","commonSituations":"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.","solutions":["Read the HTTP status code in the message and check the sidecar's logs for the corresponding server-side error.","Verify the sidecar's FUNCTION_SIGNATURES_ENDPOINT path matches the sidecar binary's actual API route (version alignment).","Confirm the sidecar process is healthy by hitting the endpoint manually with curl from the driver host.","Ensure the sidecar was launched with correct metadata/function-manifest inputs so it can serve signatures."],"exampleFix":"// before: immediate fatal throw on non-2xx\nif (!response.isSuccessful()) {\n    throw new PrestoException(GENERIC_INTERNAL_ERROR,\n            String.format(\"Metadata sidecar returned HTTP %d for %s\", response.code(), endpoint));\n}\n// after: bounded retry for transient 5xx\nif (!response.isSuccessful() && response.code() >= 500) {\n    if (retryAttempt < MAX_RETRIES) {\n        return fetchFromSidecarWithRetry(retryAttempt + 1);\n    }\n}\nthrow new PrestoException(GENERIC_INTERNAL_ERROR,\n        String.format(\"Metadata sidecar returned HTTP %d for %s\", response.code(), endpoint));","handlingStrategy":"retry","validationCode":"// pre-flight: verify the sidecar endpoint is healthy before registering functions\ntry (Response r = httpClient.newCall(new Request.Builder()\n        .url(sidecarUri.resolve(\"/v1/function-signatures\").toString()).get().build()).execute()) {\n    if (!r.isSuccessful()) {\n        throw new IllegalStateException(\"Sidecar unhealthy, HTTP \" + r.code());\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    List<? extends SqlFunction> fns = registryTool.getWorkerFunctions();\n} catch (PrestoException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Metadata sidecar returned HTTP\")) {\n        // parse status from message; retry only for 5xx, fail fast for 4xx\n        log.error(\"Sidecar metadata fetch failed: %s\", e.getMessage());\n    }\n    throw e;\n}","preventionTips":["Pin sidecar binary and driver tool versions together so endpoint routes always match.","Health-check the sidecar endpoint before function registration in driver startup.","Test the endpoint with curl from the driver host to isolate proxy/network interference.","Alert on sidecar-side 5xx rates to catch metadata-load failures early."],"tags":["http","sidecar","udf","presto-spark"],"backgroundTag":"http-non-200-response","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"}