apache/dolphinscheduler · error · RuntimeException

Post request execute failed, url: %s

Error message

Post request execute failed, url: %s

What it means

OkHttpUtils.post executes an OkHttp HTTP POST call and wraps any exception thrown during execute() or body reading into a RuntimeException formatted with the request URL, preserving the original cause. It signals the POST request could not be completed at the transport level (not an HTTP error status, which is returned as-is).

Source

Thrown at dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OkHttpUtils.java:96

                                               @Nullable OkHttpRequestHeaders okHttpRequestHeaders,
                                               @Nullable Map<String, Object> requestParamsMap,
                                               @Nullable Map<String, Object> requestBodyMap,
                                               int connectTimeout,
                                               int writeTimeout,
                                               int readTimeout) throws IOException {
        OkHttpClient client = getHttpClient(connectTimeout, writeTimeout, readTimeout);
        String finalUrl = addUrlParams(requestParamsMap, url);
        Request.Builder requestBuilder = new Request.Builder().url(finalUrl);
        addHeader(okHttpRequestHeaders.getHeaders(), requestBuilder);
        if (requestBodyMap != null) {
            requestBuilder = requestBuilder.post(RequestBody.create(
                    JSONUtils.toJsonString(requestBodyMap),
                    MediaType.parse(okHttpRequestHeaders.getOkHttpRequestHeaderContentType().getValue())));
        }
        try (Response response = client.newCall(requestBuilder.build()).execute()) {
            return new OkHttpResponse(response.code(), getResponseBody(response));
        } catch (Exception e) {
            throw new RuntimeException(String.format("Post request execute failed, url: %s", url), e);
        }
    }

    /**
     * http put request
     * @param connectTimeout connect timeout in milliseconds
     * @param writeTimeout write timeout in milliseconds
     * @param readTimeout read timeout in milliseconds
     * @return OkHttpResponse
     * @throws RuntimeException
     */
    public static @NonNull OkHttpResponse put(@NonNull String url,
                                              @Nullable OkHttpRequestHeaders okHttpRequestHeaders,
                                              @Nullable Map<String, Object> requestBodyMap,
                                              int connectTimeout,
                                              int writeTimeout,
                                              int readTimeout) throws IOException {
        OkHttpClient client = getHttpClient(connectTimeout, writeTimeout, readTimeout);

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Inspect the wrapped cause to identify connection vs timeout vs DNS problem
  2. Verify the endpoint with curl -X POST and correct payload
  3. Raise connect/read timeouts and add retry/backoff for transient network failures

Example fix

// before
OkHttpResponse resp = OkHttpUtils.post(unreachableUrl, headers, body);
// after
// pre-check reachability, then retry on transient errors
OkHttpResponse resp = retryablePost(url, headers, body, /*maxRetries=*/3);
Defensive patterns

Strategy: retry

Validate before calling

if (!url.startsWith("http")) throw new IllegalArgumentException("Invalid URL: " + url);
// confirm endpoint accepts POST before production use (contract test)

Try / catch

try { return OkHttpUtils.post(url, headers, body); } catch (RuntimeException e) { if (isTransient(e.getCause())) return retryPost(url, headers, body, 3); throw e; }

Prevention

When it happens

Trigger: Calling OkHttpUtils.post(url, ...) when the connection fails, times out, DNS resolution fails, TLS fails, or reading the response body throws.

Common situations: Target API server down or URL wrong; long-running uploads hitting read timeout; network egress blocked; JSON body serialization succeeding but transport failing due to proxy/firewall.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06). Data as JSON: /api/errors/7ddf8902fe13877f. Report an issue: GitHub.