{"record":{"id":"9b676d264e9fc531","repo":"elastic/elasticsearch","slug":"failed-to-call-api-endpoint-to-submit-updated-depe","errorCode":null,"errorMessage":"Failed to call API endpoint to submit updated dependency graph","messagePattern":"Failed to call API endpoint to submit updated dependency graph","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/snyk/UploadSnykDependenciesGraph.java","lineNumber":76,"sourceCode":"    @TaskAction\n    void upload() {\n        String endpoint = calculateEffectiveEndpoint();\n        CloseableHttpResponse response;\n        try (CloseableHttpClient client = HttpClients.createDefault()) {\n            HttpPut putRequest = new HttpPut(endpoint);\n            putRequest.addHeader(\"Authorization\", \"token \" + token.get());\n            putRequest.addHeader(\"Content-Type\", \"application/json\");\n            putRequest.setEntity(new FileEntity(inputFile.getAsFile().get(), ContentType.APPLICATION_JSON));\n            response = client.execute(putRequest);\n            int statusCode = response.getCode();\n            String responseString = EntityUtils.toString(response.getEntity());\n            getLogger().info(\"Snyk API call response status: \" + statusCode);\n            if (statusCode != HttpURLConnection.HTTP_CREATED) {\n                throw new GradleException(\"Uploading Snyk Graph failed with http code \" + statusCode + \": \" + responseString);\n            }\n            getLogger().info(responseString);\n        } catch (IOException | ParseException e) {\n            throw new GradleException(\"Failed to call API endpoint to submit updated dependency graph\", e);\n        }\n    }\n\n    private String calculateEffectiveEndpoint() {\n        String url = this.url.get();\n        return snykOrganisation.map(id -> url + \"?org=\" + id).getOrElse(url);\n    }\n\n    @Input\n    public Property<String> getToken() {\n        return token;\n    }\n\n    @Input\n    public Property<String> getUrl() {\n        return url;\n    }\n","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/snyk/UploadSnykDependenciesGraph.java#L58-L94","documentation":"GradleException wrapping IOException or ParseException thrown while executing the Snyk dependency-graph HTTP PUT or while parsing its response entity. This is the transport-level failure, distinct from the non-201 status error at line 72.","triggerScenarios":"client.execute(putRequest) raises IOException (DNS failure, connection reset, socket timeout, TLS handshake error) or EntityUtils.toString raises ParseException on a malformed response body.","commonSituations":"CI agent cannot reach api.snyk.io due to firewall/proxy; corporate TLS inspection breaks the handshake; intermittent network blip; misconfigured http proxyHost system properties; response truncated mid-stream.","solutions":["Verify network egress to the Snyk endpoint (curl the URL with the token from the same host).","Configure JVM proxy settings (-Dhttps.proxyHost/-Dhttps.proxyPort) if behind a corporate proxy.","Retry the upload task - transient IOExceptions often resolve on the next run.","Inspect the wrapped exception's class to distinguish IOException (network) from ParseException (response parsing)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Pre-flight connectivity check before the upload\ntry (Socket s = new Socket()) {\n    s.connect(new InetSocketAddress(new URL(endpoint).getHost(), 443), 5000);\n} catch (IOException e) {\n    throw new GradleException(\"No route to Snyk endpoint \" + endpoint, e);\n}","typeGuard":null,"tryCatchPattern":"IOException last = null;\nfor (int attempt = 1; attempt <= 3; attempt++) {\n    try (CloseableHttpClient client = HttpClients.createDefault()) {\n        // execute and return on success\n        return;\n    } catch (IOException e) {\n        last = e;\n    }\n}\nthrow new GradleException(\"Failed to call API endpoint after retries\", last);","preventionTips":["Configure JVM proxy properties for corporate networks.","Whitelist the Snyk API host in firewall egress rules.","Add bounded retry-with-backoff for transient network failures."],"tags":["snyk","http","network","ioexception","build-tooling"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}