rahulsmahadev commented on code in PR #18878:
URL: https://github.com/apache/iceberg/pull/18878#discussion_r4733868243


##########
core/src/main/java/org/apache/iceberg/rest/HTTPClient.java:
##########
@@ -169,6 +170,33 @@ public HTTPClient withAuthSession(AuthSession session) {
     return new HTTPClient(this, session);
   }
 
+  @VisibleForTesting
+  static String userAgent(String override, String prefix) {
+    if (override != null) {
+      // the HTTP client silently replaces characters outside visible ASCII 
with '?'
+      Preconditions.checkArgument(

Review Comment:
   Good catch, that would have been a breaking change, and the client is built 
from the merged config, so a server-returned value would have failed too. 
`rest.client.user-agent` is sent as is again, and I dropped its ASCII note from 
the docs and the PR description. The new prefix keeps the check, since it has 
no existing behavior to preserve.
   



##########
docs/docs/rest-catalog.md:
##########
@@ -90,7 +90,8 @@ at connection time through
 | `rest.client.connections-per-route` | `100`   | Maximum number of pooled 
connections per route.                                                          
                                                                                
                                                                                
                                           |
 | `rest.client.connection-timeout-ms` | null    | Timeout in milliseconds for 
establishing a connection to the server. If not set, the HTTP client library 
default is used.                                                                
                                                                                
                                           |
 | `rest.client.socket-timeout-ms`     | null    | Socket timeout in 
milliseconds for awaiting data on a connection. If not set, the HTTP client 
library default is used.                                                        
                                                                                
                                                      |
-| `rest.client.user-agent`            | null    | Custom `User-Agent` header 
value to send with each request. If not set, the HTTP client library default is 
used.                                                                           
                                                                                
                                         |
+| `rest.client.user-agent`            | null    | Replaces the whole 
`User-Agent` header. If unset, the header is `iceberg-java/<version> (jvm <java 
version>)`, after any tokens from `rest.client.user-agent.prefix`. Only visible 
ASCII characters and spaces are allowed.                                        
                                                 |
+| `rest.client.user-agent.prefix`     | null    | Client application's product 
tokens, such as `Trino/438`, sent before the `iceberg-java` token in the 
`User-Agent` header. Ignored if `rest.client.user-agent` is set. Only visible 
ASCII characters and spaces are allowed.                                        
                                                |

Review Comment:
   Makes sense, and failing is also the safer start, since we can allow both 
later without breaking anyone. Setting both now fails when the client is built, 
and the docs say so. The Spark, Flink and Kafka Connect follow-up only adds the 
prefix when `rest.client.user-agent` isn't set, so they keep working.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to