{"record":{"id":"3a788d0554284f9a","repo":"prestodb/presto","slug":"failed-to-parse-uri-for-field-s","errorCode":null,"errorMessage":"Failed to parse URI for field '%s'","messagePattern":"Failed to parse URI for field '(.+?)'","errorType":"exception","errorClass":"ClientException","httpStatus":null,"severity":"error","filePath":"presto-client/src/main/java/com/facebook/presto/client/auth/external/ExternalAuthenticator.java","lineNumber":116,"sourceCode":"                Optional<URI> tokenUri = parseField(challenge.authParams(), TOKEN_URI_FIELD);\n                Optional<URI> redirectUri = parseField(challenge.authParams(), REDIRECT_URI_FIELD);\n                if (tokenUri.isPresent()) {\n                    return Optional.of(new ExternalAuthentication(tokenUri.get(), redirectUri));\n                }\n            }\n        }\n\n        return Optional.empty();\n    }\n\n    private static Optional<URI> parseField(Map<String, String> fields, String key)\n    {\n        return Optional.ofNullable(fields.get(key)).map(value -> {\n            try {\n                return new URI(value);\n            }\n            catch (URISyntaxException e) {\n                throw new ClientException(format(\"Failed to parse URI for field '%s'\", key), e);\n            }\n        });\n    }\n}\n","sourceCodeStart":98,"sourceCodeEnd":121,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-client/src/main/java/com/facebook/presto/client/auth/external/ExternalAuthenticator.java#L98-L121","documentation":"ExternalAuthenticator.parseField extracts a URI-valued field from the challenge/realm attributes sent by the server (used for redirectUri and tokenUri). If the field value cannot be parsed as a URI, it throws this ClientException wrapping the URISyntaxException, aborting the external authentication handshake.","triggerScenarios":"Server responds to an unauthenticated request with an external-authentication challenge whose attribute (e.g. tokenUri or redirectUri field) is missing its scheme, contains illegal characters, spaces, or is otherwise not a valid URI, so new URI(value) throws URISyntaxException.","commonSituations":"Misconfigured authentication service behind the coordinator emitting malformed realm attributes; a proxy that mangles or HTML-rewrites the WWW-Authenticate header; version mismatch where the auth server sends fields the client URI-parses strictly.","solutions":["Inspect the WWW-Authenticate / challenge response and fix the tokenUri/redirectUri value emitted by the authentication service to be a well-formed absolute URI (with scheme, e.g. https://...).","Check the cause (getCause(), URISyntaxException) to see the exact offending character/index and correct the auth server configuration.","Bypass or upgrade any intermediary proxy that alters the authentication headers.","Upgrade/align the authentication service and Presto client versions so the expected field format matches."],"exampleFix":"// before (auth service config)\ntokenUri: auth.internal.example.com/token\n// after\ntokenUri: https://auth.internal.example.com/token","handlingStrategy":"try-catch","validationCode":"String value = fields.get(\"tokenUri\");\nif (value == null || !URI.create(value.trim()).isAbsolute()) {\n    throw new IllegalArgumentException(\"tokenUri field is not an absolute URI: \" + value);\n}","typeGuard":"boolean isAbsoluteUri(String s) {\n    try { return s != null && new URI(s.trim()).isAbsolute(); }\n    catch (URISyntaxException e) { return false; }\n}","tryCatchPattern":"try {\n    authenticate(session, fields);\n} catch (ClientException e) {\n    if (e.getCause() instanceof URISyntaxException) {\n        throw new IllegalStateException(\"Bad auth challenge URI: \" + e.getCause().getMessage(), e);\n    }\n    throw e;\n}","preventionTips":["Ensure the authentication service emits absolute http(s) URIs in challenge fields.","Trim and normalize challenge values before URI parsing.","Inspect the URISyntaxException detail (index/character) when debugging auth config.","Keep auth service and Presto client versions aligned on the challenge format."],"tags":["authentication","uri-parsing","external-auth"],"backgroundTag":"invalid-uri-format","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"}