fix folder causing 500 toast when deleted on another machine (#6551)

This commit is contained in:
Anthony Stirling
2026-06-09 18:00:02 +01:00
committed by GitHub
parent 1a0beaffc2
commit 502f6c1e4d
4 changed files with 350 additions and 27 deletions
@@ -18,6 +18,7 @@ import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.context.MessageSource;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ProblemDetail;
import org.springframework.http.ResponseEntity;
@@ -27,6 +28,7 @@ import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.multipart.MaxUploadSizeExceededException;
import org.springframework.web.multipart.support.MissingServletRequestPartException;
import org.springframework.web.servlet.NoHandlerFoundException;
import org.springframework.web.servlet.resource.NoResourceFoundException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@@ -208,6 +210,19 @@ class GlobalExceptionHandlerTest {
assertEquals(HttpStatus.NOT_FOUND, resp.getStatusCode());
}
// ---- NoResourceFoundException ----
// Regression guard: was falling through to the 500 catch-all.
@Test
void handleNoResourceFound_returns_404_not_500() {
when(request.getMethod()).thenReturn("GET");
NoResourceFoundException ex =
new NoResourceFoundException(HttpMethod.GET, "/api/v1/storage/folders", "");
ResponseEntity<ProblemDetail> resp = handler.handleNoResourceFound(ex, request);
assertEquals(HttpStatus.NOT_FOUND, resp.getStatusCode());
assertEquals("GET", resp.getBody().getProperties().get("method"));
}
// ---- IllegalArgumentException ----
@Test