rmetzger commented on code in PR #38:
URL:
https://github.com/apache/flink-connector-http/pull/38#discussion_r3078711244
##########
flink-connector-http/src/main/java/org/apache/flink/connector/http/table/lookup/querycreators/GenericJsonAndUrlQueryCreator.java:
##########
@@ -132,9 +134,15 @@ public LookupQueryInfo createLookupQuery(final RowData
lookupDataRow) {
}
// Parameters are encoded as query params for GET and none GET.
// Later code will turn these query params into the body for PUTs and
POSTs
+ // Use the map to rename columns to query param keys
ObjectNode jsonObjectForQueryParams =
ObjectMapperAdapter.instance().createObjectNode();
- for (String requestColumnName : this.requestQueryParamsFields) {
- jsonObjectForQueryParams.set(requestColumnName,
jsonObject.get(requestColumnName));
+ for (Map.Entry<String, String> entry :
this.requestQueryParamsMap.entrySet()) {
+ String columnName = entry.getKey();
+ String queryParamKey = entry.getValue();
+ JsonNode value = jsonObject.get(columnName);
+ if (value != null) {
+ jsonObjectForQueryParams.set(queryParamKey, value);
+ }
Review Comment:
My AI tells me:
```java
JsonNode value = jsonObject.get(columnName);
if (value != null) {
jsonObjectForQueryParams.set(queryParamKey, value);
}
```
If a user configures `'http.request.query-param-fields-with-key' =
'misspelledCol:customer'`, the query parameter is **silently omitted** from the
HTTP request. No error, no warning. Compare this to `substituteTemplate()` at
line 191 which correctly throws `IllegalArgumentException` for missing fields —
the two code paths have inconsistent error handling for the same class of
problem.
**Recommendation:** Throw an `IllegalArgumentException` with the
misconfigured column name and available columns, consistent with
`substituteTemplate()`.
--
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]