{"record":{"id":"1078a2ce8ba87dbd","repo":"apache/seatunnel","slug":"failed-to-parse-shallow-keys-from-firebase-respons","errorCode":null,"errorMessage":"Failed to parse shallow keys from Firebase response","messagePattern":"Failed to parse shallow keys from Firebase response","errorType":"exception","errorClass":"SeaTunnelException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-firebase/src/main/java/org/apache/seatunnel/connectors/seatunnel/firebase/client/FirebaseHttpClient.java","lineNumber":117,"sourceCode":"        return parseShallowKeys(jsonResponse);\n    }\n\n    /** Parses the JSON payload returned by a shallow scan query. */\n    List<String> parseShallowKeys(String jsonResponse) {\n        if (jsonResponse == null || jsonResponse.trim().equals(\"null\")) {\n            return Collections.emptyList();\n        }\n        String trimmed = jsonResponse.trim();\n        if (!trimmed.startsWith(\"{\")) {\n            return Collections.emptyList();\n        }\n\n        try {\n            Map<String, Boolean> keysMap =\n                    OBJECT_MAPPER.readValue(trimmed, new TypeReference<Map<String, Boolean>>() {});\n            return new ArrayList<>(keysMap.keySet());\n        } catch (Exception e) {\n            throw new SeaTunnelException(\"Failed to parse shallow keys from Firebase response\", e);\n        }\n    }\n\n    /**\n     * Fetches the raw JSON payload for a given sub-path or individual node key. Endpoint: GET\n     * /<path>/<nodeKey>.json\n     */\n    public String fetchNodeData(String nodeKey) {\n        String targetPath =\n                nodeKey == null || nodeKey.isEmpty() ? this.path : this.path + \"/\" + nodeKey;\n\n        String endpointUrl = buildUrl(targetPath, null, true);\n        return executeGet(endpointUrl);\n    }\n\n    /** Constructs a full REST URL with .json extension and query string parameters. */\n    String buildUrl(String subPath, String extraQueryParam, boolean includeExtraParams) {\n        StringBuilder urlBuilder = new StringBuilder(baseUrl);","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-firebase/src/main/java/org/apache/seatunnel/connectors/seatunnel/firebase/client/FirebaseHttpClient.java#L99-L135","documentation":"parseShallowKeys parses the JSON response of a Firebase shallow REST query expecting an object mapping keys to booleans (Map<String, Boolean>). If the body is malformed JSON or not a JSON object, Jackson fails and the error is wrapped in a SeaTunnelException. It signals the Firebase endpoint returned something the client could not interpret as a shallow key listing.","triggerScenarios":"GET /<path>.json?shallow=true returning HTML (auth error page), a plain string, an array, or truncated/invalid JSON; proxy or firewall injecting an error page; expired auth token returning a non-object error body.","commonSituations":"Wrong base URL pointing at a non-Firebase host; missing/invalid auth producing HTML error responses; path pointing at a leaf value (string/number) instead of a node; network middleware (captive portal) corrupting responses.","solutions":["Log/inspect the underlying cause 'e' to see the raw response; verify the URL returns real JSON (curl the endpoint).","Check authentication: ensure service account credentials or auth token are valid so Firebase returns JSON, not an HTML error page.","Confirm the configured path points to an object node, not a scalar leaf.","Validate the base URL has no typos and no proxy is rewriting the response."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"String body = executeGet(url);\nString trimmed = body == null ? \"\" : body.trim();\nif (!trimmed.startsWith(\"{\")) throw new IllegalStateException(\"non-JSON shallow keys response: \" + trimmed);","typeGuard":null,"tryCatchPattern":"try { keys = client.fetchShallowKeys(); } catch (SeaTunnelException e) { log.error(\"shallow keys parse failed\", e.getCause()); throw e; }","preventionTips":["Curl the shallow endpoint first to confirm JSON output","Ensure auth is valid so Firebase does not return HTML error pages","Point the path at an object node, not a scalar","Check for proxies rewriting response bodies"],"tags":["firebase","json","parsing","http"],"backgroundTag":"json-unmarshal-failed","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"}