chore(backend): migrate HTTP 422 title from UNPROCESSABLE_ENTITY to UNPROCESSABLE CONTENT (per RFC 9110) - #7142
Conversation
Spring Framework 7 follows RFC 9110 in renaming HTTP 422 from "Unprocessable Entity" to "Unprocessable Content", deprecating HttpStatus.UNPROCESSABLE_ENTITY and StatusResultMatchers.isUnprocessableEntity(). Those two accounted for every one of the 94 Kotlin compiler warnings in the backend build. The test matchers assert on the status code, which is unchanged, so that rename is mechanical. Two of the three main-source uses are inert: @ResponseStatus sets no reason attribute, and SubmissionMetrics tags with status.value() -> "422". The one behavioural change is that ExceptionHandler derives the ProblemDetail title from the status reason phrase, so 422 responses now report title "Unprocessable Content" instead of "Unprocessable Entity". Spring already treated the new phrase as canonical -- HttpStatus.valueOf(422) returns UNPROCESSABLE_CONTENT, so any 422 without an explicitly set title already rendered it -- and nothing branches on the title: the website parses it as an opaque string and the preprocessing pipeline matches on the status code. compileKotlin + compileTestKotlin warnings: 94 -> 0. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Claude finished @corneliusroemer-agent's task in 3m 41s —— View job Review:
|
| Consumer | How it matches 422 | Affected |
|---|---|---|
preprocessing/.../backend.py:161 |
case HTTPStatus.UNPROCESSABLE_ENTITY (integer 422) |
No |
website/.../DataUploadForm.tsx:636 |
case 422: on error.response.status; ignores title on that branch |
No |
website/.../backendApi.ts |
{ status: 422, schema: problemDetail }; title is an opaque z.string() |
No |
metrics/SubmissionMetrics.kt:57 |
.tag(STATUS_TAG, status.value().toString()) → "422" |
No |
cli/, ena-submission/, ingest/, integration-tests/, docs/ |
no 422 / Unprocessable references at all |
No |
No checked-in OpenAPI snapshot to regenerate (backend/docs/ holds only PlantUML + schema.sql), and no docs page documents ProblemDetail titles.
The title behaviour change is correctly scoped. ExceptionHandler.responseEntity sets title = httpStatus.reasonPhrase explicitly (ExceptionHandler.kt:126), so this really is the one visible change, and it moves 422 onto the phrase Spring already treats as canonical for HttpStatus.valueOf(422). Calling it out in the PR body was the right call — it is externally visible on the public API, even if nothing in this repo branches on it.
Nits (neither blocking):
- One inline comment on stale exception names in
ExceptionHandlerTest. - Test display names are now inconsistent:
ExceptionHandlerTestsays "Unprocessable Content", while ~25 names elsewhere still say "unprocessable entity" (e.g.SubmitProcessedDataEndpointTest.kt:262,SeqSetValidationEndpointsTest.kt:40). Purely cosmetic — the domain class is stillUnprocessableEntityException, so leaving the prose as "entity" is defensible; just pick one direction. Fix this →
Not verified locally: I could not run ./gradlew in this environment (permission denied), so I relied on CI. backend-image (compiles main sources) and website-tests both passed, confirming HttpStatus.UNPROCESSABLE_CONTENT resolves under Boot 4.1.0. backend-tests and Integration tests were still running when I finished — those are what actually exercise status().isUnprocessableContent, so please confirm they go green before merging.
No security, performance, or error-handling concerns: no logic, control flow, queries, or resource handling were touched.
· chore/spring7-unprocessable-content
|
This PR may be related to: #6976 and #7103.
Flagging for awareness; this PR does not claim to close either issue. |
…hrow Both test names referenced exception classes that no longer exist: InvalidSequenceFileException was removed in 694bda1, and ProcessingException never existed as a class. Neither appeared anywhere in the repo outside these two names, while the bodies throw UnprocessableEntityException and ProcessingValidationException respectively. Matches the sibling test, which names the exception it throws. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Claude finished @corneliusroemer's task in 1m 36s —— View job Review:
|
There was a problem hiding this comment.
Pull request overview
Migrates HTTP 422 handling to Spring Framework 7’s RFC 9110 terminology, changing the title to “Unprocessable Content.”
Changes:
- Replaces deprecated 422 status constants and matchers.
- Updates backend assertions and website fixtures.
- Updates exception handling and metrics status usage.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated no comments.
Show a summary per file
| File | Summary |
|---|---|
website/src/services/backendClient.spec.ts |
Updates the 422 title fixture. |
backend/src/test/kotlin/org/loculus/backend/service/submission/UseNewerProcessingPipelineVersionTaskTest.kt |
Updates 422 assertions. |
backend/src/test/kotlin/org/loculus/backend/controller/submission/SubmitProcessedDataEndpointTest.kt |
Updates 422 assertions. |
backend/src/test/kotlin/org/loculus/backend/controller/submission/SubmitExternalMetadataEndpointTest.kt |
Updates 422 assertions. |
backend/src/test/kotlin/org/loculus/backend/controller/submission/SubmitEndpointTest.kt |
Updates 422 assertions. |
backend/src/test/kotlin/org/loculus/backend/controller/submission/SubmitEndpointFileSharingTest.kt |
Updates 422 assertions. |
backend/src/test/kotlin/org/loculus/backend/controller/submission/SubmitEditedSequenceEntryVersionEndpointTest.kt |
Updates 422 assertions. |
backend/src/test/kotlin/org/loculus/backend/controller/submission/RevokeEndpointTest.kt |
Updates 422 assertions. |
backend/src/test/kotlin/org/loculus/backend/controller/submission/ReviseEndpointTest.kt |
Updates 422 assertions. |
backend/src/test/kotlin/org/loculus/backend/controller/submission/GetSubmittedMetadataEndpointTest.kt |
Updates 422 assertions. |
backend/src/test/kotlin/org/loculus/backend/controller/submission/GetDataToEditEndpointTest.kt |
Updates 422 assertions. |
backend/src/test/kotlin/org/loculus/backend/controller/submission/DeleteSequencesEndpointTest.kt |
Updates 422 assertions. |
backend/src/test/kotlin/org/loculus/backend/controller/submission/ApproveProcessedDataEndpointTest.kt |
Updates 422 assertions. |
backend/src/test/kotlin/org/loculus/backend/controller/seqsetcitations/SeqSetValidationEndpointsTest.kt |
Updates 422 assertions. |
backend/src/test/kotlin/org/loculus/backend/controller/seqsetcitations/SeqSetEndpointsTest.kt |
Updates 422 assertions. |
backend/src/test/kotlin/org/loculus/backend/controller/seqsetcitations/CitationEndpointsTest.kt |
Updates 422 assertions. |
backend/src/test/kotlin/org/loculus/backend/controller/files/CompleteMultipartUploadEndpointTest.kt |
Updates multipart error assertions. |
backend/src/test/kotlin/org/loculus/backend/controller/ExceptionHandlerTest.kt |
Verifies the updated 422 title and matcher. |
backend/src/test/kotlin/org/loculus/backend/controller/debug/DeleteAllSequenceDataEndpointTest.kt |
Updates processing-pipeline error assertions. |
backend/src/test/kotlin/org/loculus/backend/controller/datauseterms/DataUseTermsControllerTest.kt |
Updates data-use-term error assertions. |
backend/src/main/kotlin/org/loculus/backend/controller/SubmissionController.kt |
Uses the new 422 status constant for metrics. |
backend/src/main/kotlin/org/loculus/backend/controller/ExceptionHandler.kt |
Uses the new 422 status constant and title. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
I had a look and there is still references in the backend to the |
Fix backend warnings
'val isUnprocessableEntity: ResultMatcher' is deprecated. Deprecated in Java.Spring Framework 7 (Boot 4.1.0) follows RFC 9110 §15.5.21 in renaming HTTP 422 from Unprocessable Entity to Unprocessable Content.
titlechanges, in line with RFC 9110{ "type": "about:blank", - "title": "Unprocessable Entity", + "title": "Unprocessable Content", "status": 422, "detail": "..." }🚀 Preview: https://chore-spring7-unprocessab.loculus.org