{"record":{"id":"8bfd4746745340d2","repo":"prestodb/presto","slug":"hive-ranger-server-error-8bfd47","errorCode":"HIVE_RANGER_SERVER_ERROR","errorMessage":"Unable to fetch policies from %s hive service end point","messagePattern":"Unable to fetch policies from (.+?) hive service end point","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-hive/src/main/java/com/facebook/presto/hive/security/ranger/RangerBasedAccessControl.java","lineNumber":143,"sourceCode":"        }\n        catch (Exception e) {\n            throw new RuntimeException(\"Unable to query ranger service \", e);\n        }\n    }\n\n    private ServicePolicies getHiveServicePolicies(RangerBasedAccessControlConfig config)\n    {\n        URI uri = uriBuilderFrom(URI.create(config.getRangerHttpEndPoint()))\n                .appendPath(RANGER_REST_POLICY_MGR_DOWNLOAD_URL + \"/\" + config.getRangerHiveServiceName())\n                .build();\n        Request request = setContentTypeHeaders(prepareGet())\n                .setUri(uri)\n                .build();\n        try {\n            return OBJECT_MAPPER.readValue(httpClient.execute(request, createStringResponseHandler()).getBody(), ServicePolicies.class);\n        }\n        catch (IOException e) {\n            throw new PrestoException(HIVE_RANGER_SERVER_ERROR, format(\"Unable to fetch policies from %s hive service end point\", config.getRangerHiveServiceName()), e);\n        }\n    }\n\n    private Users getUsers(RangerBasedAccessControlConfig config)\n    {\n        URI uri = uriBuilderFrom(URI.create(config.getRangerHttpEndPoint()))\n                .appendPath(RANGER_REST_USER_GROUP_URL)\n                .build();\n        Request request = setContentTypeHeaders(prepareGet())\n                .setUri(uri)\n                .build();\n\n        return httpClient.execute(request, createJsonResponseHandler(USER_INFO_CODEC));\n    }\n\n    private static Request.Builder setContentTypeHeaders(Request.Builder requestBuilder)\n    {\n        return requestBuilder","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/security/ranger/RangerBasedAccessControl.java#L125-L161","documentation":"The HTTP response from the Ranger admin's policies endpoint could not be deserialized into ServicePolicies (IOException), thrown as PrestoException HIVE_RANGER_SERVER_ERROR. Either the request failed at transport level or the body was not valid/expected JSON.","triggerScenarios":"getHiveServicePolicies executes the HTTP GET to the Ranger REST endpoint during RangerBasedAccessControl construction and OBJECT_MAPPER.readValue fails to parse the response body, or the connection breaks mid-read.","commonSituations":"Wrong ranger.hive.service.name causing a 404/error page body; Ranger admin returning HTML error pages; proxy or LB truncating responses; incompatible Ranger version returning a different policy JSON schema.","solutions":["Verify ranger.hive.service.name matches a real Ranger service (check the policies URL manually)","Manually curl the policies endpoint and validate the JSON response","Check Ranger admin version compatibility with the Presto Ranger plugin","Inspect network path (proxy/LB) for response truncation","Fix the endpoint URL or auth so Ranger returns the expected JSON"],"exampleFix":"// before\nranger.hive.service.name=hive_cluster\n// after\nranger.hive.service.name=cm_hive","handlingStrategy":"retry","validationCode":"// preflight: confirm the policies endpoint returns JSON\nString body = httpGet(rangerEndPoint + \"/service/plugins/policies?serviceName=\" + serviceName);\nnew JSONParser().parse(body); // throws if not valid JSON","typeGuard":null,"tryCatchPattern":"try {\n    runQuery();\n} catch (PrestoException e) {\n    if (\"HIVE_RANGER_SERVER_ERROR\".equals(e.getErrorCode().getName())\n            && e.getMessage().startsWith(\"Unable to fetch policies from\")) {\n        // verify service name and re-fetch policies after Ranger recovers\n    } else throw e;\n}","preventionTips":["Match ranger.hive.service.name exactly to the Ranger service name","Manually curl the policies endpoint to confirm JSON output","Keep Ranger admin version compatible with the Presto plugin","Remove proxies/LBs that mangle or truncate HTTP responses"],"tags":["ranger","hive","http","json-deserialization","presto-exception"],"backgroundTag":"policy-fetch-failed","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}