From 8e70450e92b5bd29e641766cc5108f66a437f0c6 Mon Sep 17 00:00:00 2001 From: Anurag Mittal <1321012+anurag4DSB@users.noreply.github.com> Date: Thu, 25 Jun 2026 13:22:13 +0200 Subject: [PATCH 1/3] OSIS-155: pin headTenant pre-create 404 to INFO, no stack trace OSIS-163 already removed the service-layer logger.error that dumped a full stack on the expected pre-create 404 during tenant activation, and routed that NotFoundException through the error boundary, which logs 4xx once at INFO with no trace. This adds regression tests so the misleading 'invalid account ID' stack trace cannot come back. No production change: a service-layer test asserts the pre-create 404 still returns NotFoundException and is never logged at ERROR/WARN with a stack trace, and a boundary test pins that the exact headTenant 404 is logged once at INFO without a trace. --- .../osis/resource/OsisErrorBoundaryTest.java | 21 +++++++++ .../impl/ScalityOsisServiceTenantTests.java | 43 +++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/osis-app/src/test/java/com/scality/osis/resource/OsisErrorBoundaryTest.java b/osis-app/src/test/java/com/scality/osis/resource/OsisErrorBoundaryTest.java index a54750aa..acd8c393 100644 --- a/osis-app/src/test/java/com/scality/osis/resource/OsisErrorBoundaryTest.java +++ b/osis-app/src/test/java/com/scality/osis/resource/OsisErrorBoundaryTest.java @@ -90,6 +90,27 @@ void testNotFoundMapsTo404LoggedOnceAtInfoWithoutTrace() { assertNull(event.getThrowableProxy(), "4xx must not carry a stack trace"); } + /** + * OSIS-155: the headTenant existence check during tenant activation throws a + * NotFoundException when the account does not exist yet. That expected 404 must be + * logged once at INFO with no stack trace, so activation no longer prints a misleading + * "invalid account ID" error even though the create that follows succeeds. + */ + @Test + void testHeadTenantPreCreateNotFoundLoggedOnceAtInfoWithoutTrace() { + final ResponseEntity response = boundary.handleResponseStatus( + new NotFoundException("Head Tenant error. Error details: The account does not exist")); + + assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode()); + assertEquals("E_NOT_FOUND", response.getBody().getCode()); + + final ILoggingEvent event = onlyLogEvent(); + assertEquals(Level.INFO, event.getLevel(), + "the expected pre-create 404 must be logged at INFO, not ERROR"); + assertNull(event.getThrowableProxy(), + "the expected pre-create 404 must not carry a stack trace"); + } + @Test void testBadRequestMapsTo400LoggedOnceAtInfo() { final ResponseEntity response = diff --git a/osis-core/src/test/java/com/scality/osis/service/impl/ScalityOsisServiceTenantTests.java b/osis-core/src/test/java/com/scality/osis/service/impl/ScalityOsisServiceTenantTests.java index b13dc5f5..97863dc8 100644 --- a/osis-core/src/test/java/com/scality/osis/service/impl/ScalityOsisServiceTenantTests.java +++ b/osis-core/src/test/java/com/scality/osis/service/impl/ScalityOsisServiceTenantTests.java @@ -1,5 +1,9 @@ package com.scality.osis.service.impl; +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.Logger; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.read.ListAppender; import com.scality.osis.model.OsisTenant; import com.scality.osis.model.PageOfTenants; import com.scality.osis.model.exception.BadRequestException; @@ -8,6 +12,7 @@ import com.scality.vaultclient.dto.*; import org.junit.jupiter.api.Test; import org.mockito.stubbing.Answer; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import com.scality.osis.model.exception.NotFoundException; @@ -399,4 +404,42 @@ void testHeadTenant400() { scalityOsisServiceUnderTest.headTenant("bad_tenant_id"); }); } + + /** + * OSIS-155: during tenant activation OSE does a headTenant existence check before the + * account exists, so the platform answers with a 404 and OSIS rethrows NotFoundException. + * That is the expected pre-create path: the service layer must not log it as an error + * nor dump a stack trace (the boundary logs the 404 once at INFO). This pins that the + * misleading "invalid account ID" stack trace stays gone after OSIS-163. + */ + @Test + void testHeadTenantPreCreateNotFoundIsNotLoggedAsError() { + // Setup: account does not exist yet, platform returns a 404 + when(vaultAdminMock.getAccount(any(GetAccountRequestDTO.class))) + .thenAnswer((Answer) invocation -> { + throw new VaultServiceException(HttpStatus.NOT_FOUND, "The account does not exist"); + }); + + final Logger serviceLogger = (Logger) LoggerFactory.getLogger(ScalityOsisServiceImpl.class); + final ListAppender appender = new ListAppender<>(); + appender.start(); + serviceLogger.addAppender(appender); + + try { + // Contract: still a 404 for the caller + assertThrows(NotFoundException.class, + () -> scalityOsisServiceUnderTest.headTenant(SAMPLE_TENANT_ID)); + + // The expected pre-create 404 must not be logged at ERROR or WARN by the service, + // and must not carry a stack trace. + assertTrue(appender.list.stream().noneMatch(e -> e.getLevel() == Level.ERROR), + "the expected pre-create 404 must not be logged at ERROR"); + assertTrue(appender.list.stream().noneMatch(e -> e.getLevel() == Level.WARN), + "the expected pre-create 404 must not be logged at WARN"); + assertTrue(appender.list.stream().allMatch(e -> e.getThrowableProxy() == null), + "the expected pre-create 404 must not dump a stack trace"); + } finally { + serviceLogger.detachAppender(appender); + } + } } From e783151df5444f66fd84a8d4231d94eeb66fc254 Mon Sep 17 00:00:00 2001 From: Anurag Mittal <1321012+anurag4DSB@users.noreply.github.com> Date: Thu, 25 Jun 2026 16:07:19 +0200 Subject: [PATCH 2/3] OSIS-155: drop redundant boundary test; the service-layer test pins the regression --- .../osis/resource/OsisErrorBoundaryTest.java | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/osis-app/src/test/java/com/scality/osis/resource/OsisErrorBoundaryTest.java b/osis-app/src/test/java/com/scality/osis/resource/OsisErrorBoundaryTest.java index acd8c393..a54750aa 100644 --- a/osis-app/src/test/java/com/scality/osis/resource/OsisErrorBoundaryTest.java +++ b/osis-app/src/test/java/com/scality/osis/resource/OsisErrorBoundaryTest.java @@ -90,27 +90,6 @@ void testNotFoundMapsTo404LoggedOnceAtInfoWithoutTrace() { assertNull(event.getThrowableProxy(), "4xx must not carry a stack trace"); } - /** - * OSIS-155: the headTenant existence check during tenant activation throws a - * NotFoundException when the account does not exist yet. That expected 404 must be - * logged once at INFO with no stack trace, so activation no longer prints a misleading - * "invalid account ID" error even though the create that follows succeeds. - */ - @Test - void testHeadTenantPreCreateNotFoundLoggedOnceAtInfoWithoutTrace() { - final ResponseEntity response = boundary.handleResponseStatus( - new NotFoundException("Head Tenant error. Error details: The account does not exist")); - - assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode()); - assertEquals("E_NOT_FOUND", response.getBody().getCode()); - - final ILoggingEvent event = onlyLogEvent(); - assertEquals(Level.INFO, event.getLevel(), - "the expected pre-create 404 must be logged at INFO, not ERROR"); - assertNull(event.getThrowableProxy(), - "the expected pre-create 404 must not carry a stack trace"); - } - @Test void testBadRequestMapsTo400LoggedOnceAtInfo() { final ResponseEntity response = From 73df8b99721c5551ab449afcf12aaf4af9dbf042 Mon Sep 17 00:00:00 2001 From: Anurag Mittal <1321012+anurag4DSB@users.noreply.github.com> Date: Thu, 25 Jun 2026 16:14:44 +0200 Subject: [PATCH 3/3] OSIS-155: drop ticket references from test comments --- .../service/impl/ScalityOsisServiceTenantTests.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osis-core/src/test/java/com/scality/osis/service/impl/ScalityOsisServiceTenantTests.java b/osis-core/src/test/java/com/scality/osis/service/impl/ScalityOsisServiceTenantTests.java index 97863dc8..797912e7 100644 --- a/osis-core/src/test/java/com/scality/osis/service/impl/ScalityOsisServiceTenantTests.java +++ b/osis-core/src/test/java/com/scality/osis/service/impl/ScalityOsisServiceTenantTests.java @@ -406,11 +406,11 @@ void testHeadTenant400() { } /** - * OSIS-155: during tenant activation OSE does a headTenant existence check before the - * account exists, so the platform answers with a 404 and OSIS rethrows NotFoundException. - * That is the expected pre-create path: the service layer must not log it as an error - * nor dump a stack trace (the boundary logs the 404 once at INFO). This pins that the - * misleading "invalid account ID" stack trace stays gone after OSIS-163. + * During tenant activation OSE does a headTenant existence check before the account + * exists, so the platform answers with a 404 and OSIS rethrows NotFoundException. That is + * the expected pre-create path: the service layer must not log it as an error nor dump a + * stack trace (the error boundary logs the 404 once at INFO). This pins that the misleading + * "invalid account ID" stack trace stays gone. */ @Test void testHeadTenantPreCreateNotFoundIsNotLoggedAsError() {