diff --git a/src/main/java/io/supertokens/webserver/WebserverAPI.java b/src/main/java/io/supertokens/webserver/WebserverAPI.java index e702bf618..eb9433c9a 100644 --- a/src/main/java/io/supertokens/webserver/WebserverAPI.java +++ b/src/main/java/io/supertokens/webserver/WebserverAPI.java @@ -82,10 +82,15 @@ public static SemVer getLatestCDIVersion() { } public SemVer getLatestCDIVersionForRequest(HttpServletRequest req) - throws ServletException, TenantOrAppNotFoundException { + throws ServletException { SemVer maxCDIVersion = getLatestCDIVersion(); - String maxCDIVersionStr = Config.getConfig( - getAppIdentifierWithoutVerifying(req).getAsPublicTenantIdentifier(), main).getMaxCDIVersion(); + String maxCDIVersionStr = null; + try { + maxCDIVersionStr = Config.getConfig( + getAppIdentifierWithoutVerifying(req).getAsPublicTenantIdentifier(), main).getMaxCDIVersion(); + } catch (TenantOrAppNotFoundException e) { + // ignore missing app + } if (maxCDIVersionStr != null) { maxCDIVersion = new SemVer(maxCDIVersionStr); } @@ -534,25 +539,21 @@ protected String getRIDFromRequest(HttpServletRequest req) { } protected SemVer getVersionFromRequest(HttpServletRequest req) throws ServletException { - try { - SemVer maxCDIVersion = getLatestCDIVersionForRequest(req); - String version = req.getHeader("cdi-version"); + SemVer maxCDIVersion = getLatestCDIVersionForRequest(req); + String version = req.getHeader("cdi-version"); - if (version != null) { - SemVer versionFromRequest = new SemVer(version); + if (version != null) { + SemVer versionFromRequest = new SemVer(version); - if (versionFromRequest.greaterThan(maxCDIVersion)) { - throw new ServletException( - new BadRequestException("cdi-version " + versionFromRequest + " not supported")); - } - - return versionFromRequest; + if (versionFromRequest.greaterThan(maxCDIVersion)) { + throw new ServletException( + new BadRequestException("cdi-version " + versionFromRequest + " not supported")); } - return maxCDIVersion; - } catch (TenantOrAppNotFoundException e) { - throw new ServletException(e); + return versionFromRequest; } + + return maxCDIVersion; } public static class BadRequestException extends Exception { diff --git a/src/test/java/io/supertokens/test/LoggingTest.java b/src/test/java/io/supertokens/test/LoggingTest.java index 6237fcdf0..91ae6a52a 100644 --- a/src/test/java/io/supertokens/test/LoggingTest.java +++ b/src/test/java/io/supertokens/test/LoggingTest.java @@ -284,9 +284,12 @@ public void testTenantNotFoundExceptionUsesTheRightCUD() throws Exception { stdOutput.reset(); errorOutput.reset(); + JsonObject body = new JsonObject(); + body.addProperty("email", "test@example.com"); + body.addProperty("password", "abcd"); try { HttpRequestForTesting.sendJsonPOSTRequest(process.getProcess(), "", - "http://localhost:3567/tenant2/recipe/signin", new JsonObject(), 1000, 1000, null, + "http://localhost:3567/tenant2/recipe/signin", body, 1000, 1000, null, Utils.getCdiVersionStringLatestForTests(), "emailpassword"); throw new Exception("Should not come here"); } catch (io.supertokens.test.httpRequest.HttpResponseException e) {