[ 
https://issues.apache.org/jira/browse/HADOOP-20003?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18139273#comment-18139273
 ] 

ASF GitHub Bot commented on HADOOP-20003:
-----------------------------------------

joseluisll opened a new pull request, #8945:
URL: https://github.com/apache/hadoop/pull/8945

   ### Description of PR
   
   Several Hadoop clients take the reason a server refused a request from the 
HTTP reason phrase; Jetty 12 sends only the canonical phrase. The same text is 
in the response body on Jetty 9.4 and Jetty 12.
   
   ResponseDetail in hadoop-auth reads a capped amount of the error body: the 
MESSAGE row of a Jetty error page, or any other page's text, falling back to 
the phrase when there is no body. It leaves the JSON error envelope alone.
   
   AuthenticatedURL, HttpExceptionUtils#validateResponse and WebHdfsFileSystem 
report failures through it. KMSClientProvider uses it to decide whether to 
reset its token and re-authenticate. WebHdfsFileSystem#jsonParse checks the 
content type before opening the stream, so a body it will not read stays 
readable.
   
   No change against Jetty 9.4 servers.
   
   ### How was this patch tested?
   
   The changed modules' tests, run by the Yetus precommit and the fork's CI on 
this branch.
   
   ### For code changes:
   
   - [x] Does the title of this PR start with the corresponding JIRA issue id?
   - [ ] Object storage: not applicable, no object store integration touched.
   - [x] If adding new dependencies: Guice 6.0.0 and javax.inject already under 
ASF-compatible licenses; LICENSE-binary updated.
   - [x] LICENSE-binary updated where the dependency tree changed.
   
   ### AI Tooling
   
   If an AI tool was used:
   
   - [x] The PR includes the phrase "Contains content generated by <tool>" 
where <tool> is the name of the AI tool used.
   - [x] My use of AI contributions follows the ASF legal policy 
https://www.apache.org/legal/generative-tooling.html
   
   Contains content generated by Claude Code.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   




> Clients shall read an HTTP refusal's reason from the response body
> ------------------------------------------------------------------
>
>                 Key: HADOOP-20003
>                 URL: https://issues.apache.org/jira/browse/HADOOP-20003
>             Project: Hadoop Common
>          Issue Type: Sub-task
>          Components: common, hadoop-auth, hdfs-client, kms
>            Reporter: Jose Luis López
>            Priority: Minor
>
> Several Hadoop clients take the reason a server refused a request from the 
> HTTP reason phrase ({{HttpURLConnection#getResponseMessage()}}). The same 
> text is also in the response body: {{sendError}} writes it into the error 
> page's MESSAGE row, which looks the same on Jetty 9.4 and on Jetty 12. Jetty 
> 12 sends no custom reason phrase (HADOOP-19972), so these clients would only 
> see the standard text, e.g. "Unauthorized" instead of "Authentication 
> required".
> h3. Changes
> * New {{ResponseDetail}} in hadoop-auth ({{@InterfaceAudience.Private}}) 
> reads a capped amount of the error body. It returns the MESSAGE row of a 
> Jetty error page, or the text of any other page with the markup stripped. It 
> falls back to the phrase when there is no body. A JSON error envelope is left 
> alone, and its phrase is reported, because that envelope is sent with 
> {{setStatus}}, not {{sendError}}.
> * {{AuthenticatedURL}} and {{HttpExceptionUtils#validateResponse}} use it to 
> report failures.
> * {{WebHdfsFileSystem}} uses it for a 401 and the neighbouring error arms.
> * {{KMSClientProvider}} uses it to decide whether to reset its token and 
> re-authenticate. That decision matches on "Invalid signature" and "Anonymous 
> requests are disallowed", which would never match the standard phrase.
> h3. Compatibility
> No change against Jetty 9.4 servers: the MESSAGE row holds exactly the text 
> the phrase carried.
> h3. Tests
> {{TestHttpExceptionUtils}} and {{TestAuthenticatedURL}} cover the body and 
> fallback cases. A new {{TestKMS}} case covers the re-authentication retry.
> h3. Not in scope
> {{NetworkTopologyServlet}} loses its reason on Jetty 9.4 too (a failed dump 
> answers 200). That needs its own JIRA.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to