apache/seatunnel · error · HttpConnectorException

REQUEST_FAILED

REQUEST_FAILED

Error message

PostHog query returned an empty response

What it means

PostHogSourceReader.collectResponse() validates the HTTP response body before parsing it. If the body is null or blank, it throws HttpConnectorException with code REQUEST_FAILED, because an empty body means the query never produced usable results and parsing would be meaningless.

Source

Thrown at seatunnel-connectors-v2/connector-http/connector-http-posthog/src/main/java/org/apache/seatunnel/connectors/seatunnel/posthog/source/PostHogSourceReader.java:107

    @Override
    public void internalPollNext(Collector<SeaTunnelRow> output) throws Exception {
        HttpResponse response =
                httpClient.doPost(
                        httpParameter.getUrl(),
                        httpParameter.getHeaders(),
                        httpParameter.getBody());
        if (response.getCode() < 200 || response.getCode() >= 300) {
            throw requestFailed(
                    "PostHog query request failed with HTTP status " + response.getCode());
        }
        collectResponse(response.getContent(), output);
        context.signalNoMoreElement();
    }

    @VisibleForTesting
    void collectResponse(String content, Collector<SeaTunnelRow> output) throws IOException {
        if (content == null || content.trim().isEmpty()) {
            throw requestFailed("PostHog query returned an empty response");
        }

        JsonNode response;
        try {
            response = JsonUtils.stringToJsonNode(content);
        } catch (Exception e) {
            throw new HttpConnectorException(
                    HttpConnectorErrorCode.REQUEST_FAILED,
                    "PostHog query returned invalid JSON",
                    e);
        }
        validateQueryStatus(response);

        JsonNode columnsNode = response.get("columns");
        JsonNode resultsNode = response.get("results");
        if (columnsNode == null || !columnsNode.isArray()) {
            throw requestFailed("PostHog query response is missing the columns array");

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Verify base_url, project_id, api_key and query options are correct in the PostHog source config.
  2. Reproduce the same query with curl against the PostHog API to inspect the raw response.
  3. Check for proxies/gateways that may return empty 2xx bodies and bypass them.
  4. Confirm the PostHog personal API key has access to the requested project and query.
Defensive patterns

Strategy: validation

Validate before calling

// Reproduce the query before running the pipeline:
curl -s -H "Authorization: Bearer $POSTHOG_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"query":{"kind":"HogQLQuery","query":"SELECT * FROM events LIMIT 1"}}' \
  https://us.posthog.com/api/environments/<project_id>/query/ | jq -e . 

Try / catch

try {
    runSeaTunnelJob(config);
} catch (HttpConnectorException e) {
    if (HttpConnectorErrorCode.REQUEST_FAILED.equals(e.getErrorCode())
            && e.getMessage().contains("empty response")) {
        log.error("PostHog returned empty body; verify base_url/project_id/api_key/query");
    }
    throw e;
}

Prevention

When it happens

Trigger: The PostHog query API returns HTTP 2xx with an empty body: e.g. a wrong/empty query returning no payload, a proxy stripping the body, or authentication issues where the API returns an empty 200/204.

Common situations: Misconfigured PostHog base_url or project_id pointing at a wrong endpoint, invalid personal API key accepted by a gateway but rejected upstream with an empty body, network middleboxes truncating responses.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/c51a7948e92f2992. Report an issue: GitHub.