{"record":{"id":"c51a7948e92f2992","repo":"apache/seatunnel","slug":"request-failed-c51a79","errorCode":"REQUEST_FAILED","errorMessage":"PostHog query returned an empty response","messagePattern":"PostHog query returned an empty response","errorType":"validation","errorClass":"HttpConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-http/connector-http-posthog/src/main/java/org/apache/seatunnel/connectors/seatunnel/posthog/source/PostHogSourceReader.java","lineNumber":107,"sourceCode":"\n    @Override\n    public void internalPollNext(Collector<SeaTunnelRow> output) throws Exception {\n        HttpResponse response =\n                httpClient.doPost(\n                        httpParameter.getUrl(),\n                        httpParameter.getHeaders(),\n                        httpParameter.getBody());\n        if (response.getCode() < 200 || response.getCode() >= 300) {\n            throw requestFailed(\n                    \"PostHog query request failed with HTTP status \" + response.getCode());\n        }\n        collectResponse(response.getContent(), output);\n        context.signalNoMoreElement();\n    }\n\n    @VisibleForTesting\n    void collectResponse(String content, Collector<SeaTunnelRow> output) throws IOException {\n        if (content == null || content.trim().isEmpty()) {\n            throw requestFailed(\"PostHog query returned an empty response\");\n        }\n\n        JsonNode response;\n        try {\n            response = JsonUtils.stringToJsonNode(content);\n        } catch (Exception e) {\n            throw new HttpConnectorException(\n                    HttpConnectorErrorCode.REQUEST_FAILED,\n                    \"PostHog query returned invalid JSON\",\n                    e);\n        }\n        validateQueryStatus(response);\n\n        JsonNode columnsNode = response.get(\"columns\");\n        JsonNode resultsNode = response.get(\"results\");\n        if (columnsNode == null || !columnsNode.isArray()) {\n            throw requestFailed(\"PostHog query response is missing the columns array\");","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-http/connector-http-posthog/src/main/java/org/apache/seatunnel/connectors/seatunnel/posthog/source/PostHogSourceReader.java#L89-L125","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify base_url, project_id, api_key and query options are correct in the PostHog source config.","Reproduce the same query with curl against the PostHog API to inspect the raw response.","Check for proxies/gateways that may return empty 2xx bodies and bypass them.","Confirm the PostHog personal API key has access to the requested project and query."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Reproduce the query before running the pipeline:\ncurl -s -H \"Authorization: Bearer $POSTHOG_API_KEY\" \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"query\":{\"kind\":\"HogQLQuery\",\"query\":\"SELECT * FROM events LIMIT 1\"}}' \\\n  https://us.posthog.com/api/environments/<project_id>/query/ | jq -e . ","typeGuard":null,"tryCatchPattern":"try {\n    runSeaTunnelJob(config);\n} catch (HttpConnectorException e) {\n    if (HttpConnectorErrorCode.REQUEST_FAILED.equals(e.getErrorCode())\n            && e.getMessage().contains(\"empty response\")) {\n        log.error(\"PostHog returned empty body; verify base_url/project_id/api_key/query\");\n    }\n    throw e;\n}","preventionTips":["Validate the query with curl/jq before putting it in the config.","Ensure no proxy strips response bodies between SeaTunnel and PostHog.","Confirm the API key has access to the configured project."],"tags":["seatunnel","posthog","http","empty-response"],"backgroundTag":"empty-response-body","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}