{"record":{"id":"3f170bc9c4befe6e","repo":"prestodb/presto","slug":"failed-to-create-credentials-from-file","errorCode":null,"errorMessage":"Failed to create Credentials from file","messagePattern":"Failed to create Credentials from file","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"presto-bigquery/src/main/java/com/facebook/presto/plugin/bigquery/BigQueryCredentialsSupplier.java","lineNumber":62,"sourceCode":"    }\n\n    private static Credentials createCredentialsFromKey(String key)\n    {\n        try {\n            return GoogleCredentials.fromStream(new ByteArrayInputStream(Base64.decodeBase64(key)));\n        }\n        catch (IOException e) {\n            throw new UncheckedIOException(\"Failed to create Credentials from key\", e);\n        }\n    }\n\n    private static Credentials createCredentialsFromFile(String file)\n    {\n        try {\n            return GoogleCredentials.fromStream(new FileInputStream(file));\n        }\n        catch (IOException e) {\n            throw new UncheckedIOException(\"Failed to create Credentials from file\", e);\n        }\n    }\n\n    Optional<Credentials> getCredentials()\n    {\n        return credentialsCreator.get();\n    }\n}\n","sourceCodeStart":44,"sourceCodeEnd":71,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-bigquery/src/main/java/com/facebook/presto/plugin/bigquery/BigQueryCredentialsSupplier.java#L44-L71","documentation":"This error is thrown by BigQueryCredentialsSupplier.createCredentialsFromFile when the GoogleCredentials.fromStream call fails to parse or read the service-account key file. It means the configured bigquery.credentials-key file could not be turned into Google credentials, usually because the path is wrong, the file is unreadable, or the JSON is not a valid Google credentials file. The original IOException is preserved as the cause.","triggerScenarios":"GoogleCredentials.fromStream(new FileInputStream(file)) throws IOException: file path (bigquery.credentials-key) does not exist, FileInputStream fails, stream read fails, or the file content is not parseable as Google credentials JSON/P12.","commonSituations":"Typo in the credentials-key path in catalog properties; key file mounted at a different path in Docker/Kubernetes; service-account JSON truncated or replaced by a placeholder; wrong key type (e.g. user JSON exported elsewhere); file permissions preventing the Presto process from reading it.","solutions":["Verify the credentials-key path in the catalog properties exists and is readable by the Presto process user","Validate the file is a complete Google service-account JSON (has client_email, private_key); re-download from GCP if truncated","If using a P12 file, supply bigquery.credentials-keyfile-password and confirm it is a P12 key, not JSON","Check file permissions (chmod 600 / correct ownership) and that the file is mounted/copied into the container image","Inspect the wrapped IOException cause in the log for the precise failure (No such file vs parse error)"],"exampleFix":"// before (broken path or bad JSON)\nbigquery.credentials-key=/etc/secrets/sa.json\n// after (verify file exists and is valid before start)\nls -l /etc/secrets/sa.json && python3 -c \"import json;json.load(open('/etc/secrets/sa.json'))\"\nbigquery.credentials-key=/etc/secrets/sa.json","handlingStrategy":"validation","validationCode":"File key = Paths.get(config.get(\"bigquery.credentials-key\")).toFile();\nif (!key.isFile() || !key.canRead()) throw new IllegalStateException(\"credentials-key missing/unreadable: \" + key);\ncom.google.gson.JsonObject o = com.google.gson.JsonParser.parseReader(new FileReader(key)).getAsJsonObject();\nif (!o.has(\"client_email\") || !o.has(\"private_key\")) throw new IllegalStateException(\"not a service-account JSON key\");","typeGuard":null,"tryCatchPattern":"try {\n    connectorContext.start();\n} catch (UncheckedIOException e) {\n    if (e.getMessage().contains(\"Failed to create Credentials from file\")) {\n        throw new PrestoException(INVALID_CONNECTOR_PROPERTIES, \"Invalid bigquery.credentials-key: \" + e.getCause().getMessage(), e);\n    }\n    throw e;\n}","preventionTips":["Validate the key file path and JSON at deployment time (config smoke test) before catalog start","Mount secrets with correct ownership/permissions readable by the Presto process user","Pin the key file in the image or use a secret manager sidecar that fails fast if absent","Log the resolved path and file size at startup without leaking the key contents"],"tags":["bigquery","google-credentials","io","configuration"],"backgroundTag":"credentials-file-load-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"}