seb-pereira commented on code in PR #17:
URL:
https://github.com/apache/flink-connector-http/pull/17#discussion_r2783445611
##########
flink-connector-http/src/main/java/org/apache/flink/connector/http/table/lookup/querycreators/GenericJsonAndUrlQueryCreatorFactory.java:
##########
@@ -152,6 +176,62 @@ public Set<ConfigOption<?>> requiredOptions() {
@Override
public Set<ConfigOption<?>> optionalOptions() {
- return Set.of(REQUEST_QUERY_PARAM_FIELDS, REQUEST_BODY_FIELDS,
REQUEST_URL_MAP);
+ return Set.of(
+ REQUEST_QUERY_PARAM_FIELDS,
+ REQUEST_BODY_FIELDS,
+ REQUEST_URL_MAP,
+ REQUEST_ADDITIONAL_BODY_JSON);
+ }
+
+ /**
+ * Validates that additional JSON fields do not override join keys.
+ *
+ * @param requestBodyFields the list of body field names (join keys for
POST/PUT)
+ * @param additionalRequestJson the additional JSON string to validate
+ * @throws IllegalArgumentException if additional JSON contains join keys
+ */
+ private void validateAdditionalJsonDoesNotOverrideJoinKeys(
+ List<String> requestBodyFields, String additionalRequestJson) {
+ if (additionalRequestJson == null ||
additionalRequestJson.trim().isEmpty()) {
+ return;
+ }
+
+ try {
+ // Parse the additional JSON to get field names
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode jsonNode = mapper.readTree(additionalRequestJson);
Review Comment:
The value of `http.request.additional-body-json` seems to be parsed twice:
- here by `mapper.readTree(additionalRequestJson`
- at merge time in
[GenericJsonAndUrlQueryCreator](https://github.com/apache/flink-connector-http/pull/17/changes#diff-e73bc96c08ecfe30b58370e4631ac5f6c936ac60dd831475508a9995b8f01f76R158)
`additionalRequestJson` could be parsed once here and
`validateAdditionalJsonDoesNotOverrideJoinKeys` to return a JsonNode that would
be used in
[createLookupQuery](https://github.com/apache/flink-connector-http/pull/17/changes#diff-e73bc96c08ecfe30b58370e4631ac5f6c936ac60dd831475508a9995b8f01f76L114)
for the merge ([example in draft
PR](https://github.com/davidradl/flink-connector-http/pull/1/changes)). WDYT?
--
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]