|
9 | 9 | import static io.airbyte.metrics.lib.ApmTraceConstants.Tags.WORKSPACE_ID_KEY;
|
10 | 10 |
|
11 | 11 | import com.fasterxml.jackson.databind.JsonNode;
|
| 12 | +import com.fasterxml.jackson.databind.node.ObjectNode; |
12 | 13 | import com.google.common.annotations.VisibleForTesting;
|
13 | 14 | import io.airbyte.analytics.TrackingClient;
|
14 | 15 | import io.airbyte.api.model.generated.CompleteDestinationOAuthRequest;
|
|
40 | 41 | import io.airbyte.validation.json.JsonValidationException;
|
41 | 42 | import java.io.IOException;
|
42 | 43 | import java.net.http.HttpClient;
|
43 |
| -import java.util.HashMap; |
44 | 44 | import java.util.List;
|
45 | 45 | import java.util.Map;
|
46 | 46 | import java.util.Optional;
|
@@ -322,23 +322,25 @@ Map<String, String> buildJsonPathFromOAuthFlowInitParameters(final Map<String, L
|
322 | 322 |
|
323 | 323 | @VisibleForTesting
|
324 | 324 | JsonNode getOauthFromDBIfNeeded(final JsonNode oAuthInputConfigurationFromDB, final JsonNode oAuthInputConfigurationFromInput) {
|
325 |
| - final Map<String, String> result = new HashMap<>(); |
326 |
| - |
327 |
| - Jsons.deserializeToStringMap(oAuthInputConfigurationFromInput) |
328 |
| - .forEach((k, v) -> { |
329 |
| - if (AirbyteSecretConstants.SECRETS_MASK.equals(v)) { |
330 |
| - if (oAuthInputConfigurationFromDB.has(k)) { |
331 |
| - result.put(k, oAuthInputConfigurationFromDB.get(k).textValue()); |
332 |
| - } else { |
333 |
| - LOGGER.warn("Missing the key {} in the config store in DB", k); |
334 |
| - } |
335 |
| - |
336 |
| - } else { |
337 |
| - result.put(k, v); |
338 |
| - } |
339 |
| - }); |
| 325 | + final ObjectNode result = (ObjectNode) Jsons.emptyObject(); |
| 326 | + |
| 327 | + oAuthInputConfigurationFromInput.fields().forEachRemaining(entry -> { |
| 328 | + final String k = entry.getKey(); |
| 329 | + final JsonNode v = entry.getValue(); |
| 330 | + |
| 331 | + // Note: This does not currently handle replacing masked secrets within nested objects. |
| 332 | + if (AirbyteSecretConstants.SECRETS_MASK.equals(v.textValue())) { |
| 333 | + if (oAuthInputConfigurationFromDB.has(k)) { |
| 334 | + result.set(k, oAuthInputConfigurationFromDB.get(k)); |
| 335 | + } else { |
| 336 | + LOGGER.warn("Missing the key {} in the config store in DB", k); |
| 337 | + } |
| 338 | + } else { |
| 339 | + result.set(k, v); |
| 340 | + } |
| 341 | + }); |
340 | 342 |
|
341 |
| - return Jsons.jsonNode(result); |
| 343 | + return result; |
342 | 344 | }
|
343 | 345 |
|
344 | 346 | @VisibleForTesting
|
|
0 commit comments