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 5e528cf5a230..26b9e12c0a37 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 @@ -43,6 +43,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.UUID; import java.util.stream.Collectors; import org.slf4j.Logger; @@ -342,10 +343,17 @@ JsonNode getOauthFromDBIfNeeded(final JsonNode oAuthInputConfigurationFromDB, fi @VisibleForTesting JsonNode getOAuthInputConfiguration(final JsonNode hydratedSourceConnectionConfiguration, final Map pathsToGet) { - return Jsons.jsonNode(pathsToGet.entrySet().stream() - .collect(Collectors.toMap( - Map.Entry::getKey, - entry -> JsonPaths.getSingleValue(hydratedSourceConnectionConfiguration, entry.getValue()).get()))); + final Map result = new HashMap<>(); + pathsToGet.forEach((k, v) -> { + final Optional configValue = JsonPaths.getSingleValue(hydratedSourceConnectionConfiguration, v); + if (configValue.isPresent()) { + result.put(k, configValue.get()); + } else { + LOGGER.warn("Missing the key {} from the config stored in DB", k); + } + }); + + return Jsons.jsonNode(result); } } 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 4b6ad812cac0..179eaf63f221 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 @@ -185,7 +185,8 @@ void testGetOAuthInputConfiguration() { final Map pathsToGet = Map.ofEntries( Map.entry("field1", "$.field1"), Map.entry("field3_1", "$.field3.field3_1"), - Map.entry("field3_2", "$.field3.field3_2")); + Map.entry("field3_2", "$.field3.field3_2"), + Map.entry("field4", "$.someNonexistentField")); final JsonNode expected = Jsons.deserialize( """