JingsongLi commented on code in PR #10106:
URL: https://github.com/apache/paimon/pull/10106#discussion_r4662133823


##########
paimon-python/pypaimon/api/rest_api.py:
##########
@@ -110,11 +112,38 @@ def __init__(self, options: Union[Options, Dict[str, 
str]], config_required: boo
             base_headers.update(
                 RESTUtil.extract_prefix_map(options, self.HEADER_PREFIX)
             )
+            override_user_agent = 
self._configured_user_agent(config_response.overrides or {})

Review Comment:
   **[P2] Honor `null` overrides that clear a default User-Agent**
   
   With no client User-Agent, a `/v1/config` response with `defaults: 
{"header.User-Agent": "default/1"}` and `overrides: {"header.User-Agent": 
null}` removes the option in `ConfigResponse.merge`. The separate lookup skips 
that `null` and restores `default/1` from the raw defaults. I verified that the 
next request sends `default/1` and a catalog reloaded from the merged options 
sends the generated SDK header. Both the Python baseline and Java send the 
generated header for both requests.
   
   Please preserve the removal when resolving the header and add a regression 
test for a same-key `null` override with no client header. [Existing 
`ConfigResponse` test for clearing a 
default](https://github.com/apache/paimon/blob/73cf38daa2c4f39b5ff5fbb4271419877082be13/paimon-python/pypaimon/tests/rest/api_test.py#L522-L528)



##########
paimon-python/pypaimon/api/rest_api.py:
##########
@@ -110,11 +112,38 @@ def __init__(self, options: Union[Options, Dict[str, 
str]], config_required: boo
             base_headers.update(
                 RESTUtil.extract_prefix_map(options, self.HEADER_PREFIX)
             )
+            override_user_agent = 
self._configured_user_agent(config_response.overrides or {})
+            default_user_agent = 
self._configured_user_agent(config_response.defaults or {})
+            if override_user_agent is not None:
+                configured_user_agent = override_user_agent
+            elif client_user_agent is not None:
+                configured_user_agent = client_user_agent
+            else:
+                configured_user_agent = default_user_agent
+            self._set_user_agent(base_headers, configured_user_agent)
 
         self.rest_auth_function = RESTAuthFunction(base_headers, auth_provider)
         self.options = options
         self.resource_paths = ResourcePaths.for_catalog_properties(options)
 
+    @classmethod
+    def _configured_user_agent(cls, options: Dict[str, str]) -> Optional[str]:
+        user_agent_value = None
+        for key, value in options.items():
+            if key.lower() == (cls.HEADER_PREFIX + "User-Agent").lower() and 
value is not None:

Review Comment:
   **[P2] Keep the `header.` configuration prefix case-sensitive**
   
   Lowercasing the full key makes `Header.User-Agent` eligible as a REST 
header. With the client option `header.User-Agent=client/1` and a server 
override `Header.User-Agent=alias/1`, the next request sends `alias/1`. Java 
and the Python baseline both require the literal `header.` prefix and send 
`client/1` for this input.
   
   Please match the configuration prefix exactly and compare the HTTP header 
name case-insensitively. [Java prefix 
handling](https://github.com/apache/paimon/blob/27e7bb8c043cc540003b6d44286a4df3387ed552/paimon-api/src/main/java/org/apache/paimon/rest/RESTUtil.java#L54-L64)



-- 
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]

Reply via email to