diff --git a/airbyte-server/src/main/java/io/airbyte/server/handlers/OAuthHandler.java b/airbyte-server/src/main/java/io/airbyte/server/handlers/OAuthHandler.java index 26b9e12c0a373..24e1bd0bbd4cf 100644 --- a/airbyte-server/src/main/java/io/airbyte/server/handlers/OAuthHandler.java +++ b/airbyte-server/src/main/java/io/airbyte/server/handlers/OAuthHandler.java @@ -9,6 +9,7 @@ import static io.airbyte.metrics.lib.ApmTraceConstants.Tags.WORKSPACE_ID_KEY; import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.common.annotations.VisibleForTesting; import io.airbyte.analytics.TrackingClient; import io.airbyte.api.model.generated.CompleteDestinationOAuthRequest; @@ -40,7 +41,6 @@ import io.airbyte.validation.json.JsonValidationException; import java.io.IOException; import java.net.http.HttpClient; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; @@ -322,23 +322,25 @@ Map buildJsonPathFromOAuthFlowInitParameters(final Map result = new HashMap<>(); - - Jsons.deserializeToStringMap(oAuthInputConfigurationFromInput) - .forEach((k, v) -> { - if (AirbyteSecretConstants.SECRETS_MASK.equals(v)) { - if (oAuthInputConfigurationFromDB.has(k)) { - result.put(k, oAuthInputConfigurationFromDB.get(k).textValue()); - } else { - LOGGER.warn("Missing the key {} in the config store in DB", k); - } - - } else { - result.put(k, v); - } - }); + final ObjectNode result = (ObjectNode) Jsons.emptyObject(); + + oAuthInputConfigurationFromInput.fields().forEachRemaining(entry -> { + final String k = entry.getKey(); + final JsonNode v = entry.getValue(); + + // Note: This does not currently handle replacing masked secrets within nested objects. + if (AirbyteSecretConstants.SECRETS_MASK.equals(v.textValue())) { + if (oAuthInputConfigurationFromDB.has(k)) { + result.set(k, oAuthInputConfigurationFromDB.get(k)); + } else { + LOGGER.warn("Missing the key {} in the config store in DB", k); + } + } else { + result.set(k, v); + } + }); - return Jsons.jsonNode(result); + return result; } @VisibleForTesting diff --git a/airbyte-server/src/test/java/io/airbyte/server/handlers/OAuthHandlerTest.java b/airbyte-server/src/test/java/io/airbyte/server/handlers/OAuthHandlerTest.java index 179eaf63f2214..08d9d2f95e530 100644 --- a/airbyte-server/src/test/java/io/airbyte/server/handlers/OAuthHandlerTest.java +++ b/airbyte-server/src/test/java/io/airbyte/server/handlers/OAuthHandlerTest.java @@ -206,7 +206,8 @@ void testGetOauthFromDBIfNeeded() { """ { "testMask": "**********", - "testNotMask": "this" + "testNotMask": "this", + "testOtherType": true } """); @@ -214,7 +215,8 @@ void testGetOauthFromDBIfNeeded() { """ { "testMask": "mask", - "testNotMask": "notThis" + "testNotMask": "notThis", + "testOtherType": true } """); @@ -222,7 +224,8 @@ void testGetOauthFromDBIfNeeded() { """ { "testMask": "mask", - "testNotMask": "this" + "testNotMask": "this", + "testOtherType": true } """);