Repository navigation
build: move to Spring Boot 4 - #185
Conversation
Spring Boot 4.1 (Spring Framework 7, Spring Security 7, Jackson 3, Hibernate Validator 9, Tomcat 11) instead of 2.7, without behaviour changes beyond those of the framework: - Modular starters (webmvc, aspectj, validation, restclient) and their test starters; javax -> jakarta; Security 7 lambda DSL with authorizeHttpRequests, which keeps error dispatches unauthorised as before; @EnableMethodSecurity; noauth without Spring Security's defaults, as with WebSecurityConfigurerAdapter(true). - Jackson 3 with spring.jackson.use-jackson2-defaults, so that the JSON of the API and of the stored tasks stays as it was. - springdoc 3 instead of Springfox: the API description is OpenAPI 3 at /v3/api-docs, and still at /v2/api-docs (an alias, to be dropped later); the generated models and stubs have OpenAPI 3 annotations. - PathPatternParser instead of AntPathMatcher; a trailing slash is ignored after Spring Security (UrlHandlerFilter), as with Spring 5. - Version overrides of the Spring Boot 2.7 era dropped; WireMock 3; Mockito's agent loaded at startup for the tests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The smoke test waits for /v3/api-docs, and checks the alias /v2/api-docs (OpenAPI 3) in both profiles, and the Swagger UI configuration of springdoc (/v3/api-docs/swagger-config) instead of the paths of Springfox. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Spring Boot 4 brings fixed versions for all findings that were accepted in .trivyignore.yaml; the file stays, with its header and an example entry. Dependabot no longer holds back Spring Security, WireMock and the OpenAPI generator; major versions of Spring Boot stay ignored. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The profile generate-swagger uses OpenAPI Generator 7.27.0 with useSpringBoot3 and useJakartaEe, so that it generates Jakarta and OpenAPI 3 annotations, as the committed stubs have now. The stubs themselves aren't regenerated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Upgrade notes for Spring Boot 4 (own properties of Spring Boot, log timestamps, error messages), the API description at /v3/api-docs with the deprecated alias /v2/api-docs, and the configuration of the Swagger UI at /v3/api-docs/swagger-config; the API, configuration and development docs and the notes of 2.0.0 follow. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- TRS lookups during task creation time out after 10 s again (connect and read), as with OkHttp, which Spring Boot 2.7 used; Spring Boot 4 uses the JDK client without timeouts. - More than 50 accepted media types, which Spring 7 refuses to sort, are taken as */*, so that the answer stays 401 instead of 500. - The YAML API description (/v3/api-docs.yaml) is public like the JSON one; documented. - Paths of the API description from the constants of ApiDocsAliasController; /swagger-ui.html no longer public (Springfox didn't serve it); the Swagger UI conditions share one check instead of one extending the other; smaller cleanups. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The fallback for many accepted media types is checked to answer JSON; the timeout test no longer repeats the constant. Comments re-flowed, and the note on 404s for unknown paths is gone from application.properties, as no property is left that it describes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideAPIReview the OpenAPI 3 description and compatibility alias alongside the generated TES API and model annotations, which define the public contract and preserve TES field names and write-only fields.
Review the generator configuration that produces the Jakarta and OpenAPI 3 API stubs, together with the existing generated stubs adapted to that public contract.
ImplementationReview the Jackson 3 conversion changes for stored Kubernetes task JSON, including compatibility behavior for tag values and output-log parsing.
Review the error-response adaptations and the trailing-slash filter, especially how request paths and error dispatches interact with security.
Review the TRS client timeout preservation and the Swagger OAuth flow construction, which keep existing task-creation lookup limits and UI authentication behavior.
UIReview how the Swagger UI is conditionally exposed and redirected, retaining its disabled-by-default behavior while switching to springdoc paths and initializer settings.
ConfigurationReview the Spring Boot 4 dependency and starter migration, dependency overrides, test agents, and OpenAPI Generator setup as one build configuration change.
Review the security-profile configuration changes, including the no-auth filter chain and resource-server authorization rules.
Review the application Jackson, springdoc, and Swagger UI properties that select compatibility defaults and public API-description paths.
Review CI smoke checks, vulnerability-ignore cleanup, and dependency-update policy for the new framework baseline.
DocumentationReview the user-facing API and upgrade documentation for the OpenAPI path migration, alias deprecation, Swagger UI configuration endpoint, and Spring Boot property changes.
TestsReview tests covering the API-description alias, OpenAPI schema contract, Swagger UI exposure and OAuth configuration, and the behavior of both security profiles.
Other changesFiles not grouped.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #185 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 51 53 +2
Lines 2262 2260 -2
Branches 254 255 +1
=========================================
- Hits 2262 2260 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 5 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="pom.xml" line_range="17" />
<code_context>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
- <version>2.7.18</version>
+ <version>4.1.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
</code_context>
<issue_to_address>
**Proxy details are ignored**
When the service runs behind a reverse proxy that supplies forwarded headers, spring Boot 4 no longer applies the `server.use-forward-headers` setting in `application.properties`, so the application ignores forwarded host, scheme, and client-address information; generated absolute URLs can use the internal service address.
Replace the legacy setting with `server.forward-headers-strategy` configured to process forwarded headers.
</issue_to_address>
### Comment 2
<location path="src/main/java/uk/ac/ebi/tsc/tesk/config/security/CustomAuthenticationEntryPoint.java" line_range="133-134" />
<code_context>
// q=0: not acceptable
accepted.removeIf(mediaType -> mediaType.getQualityValue() == 0);
- MediaType.sortBySpecificityAndQuality(accepted);
+ try {
+ MimeTypeUtils.sortBySpecificity(accepted);
+ } catch (InvalidMimeTypeException e) {
+ // more than 50 media types, which Spring refuses to sort: answer as without Accept
</code_context>
<issue_to_address>
**Error responses use lower-ranked formats**
When an `Accept` header lists equally specific writable media types with different `q` values and puts the lower-quality type first, `MimeTypeUtils.sortBySpecificity` does not sort equally specific types by quality, so `CustomAuthenticationEntryPoint.write` can select the lower-quality type; callers receive the error response in a less-preferred format.
Sort accepted media types by both specificity and quality before selecting a converter.
</issue_to_address>
### Comment 3
<location path="src/main/java/uk/ac/ebi/tsc/tesk/k8s/convert/TesKubernetesConverter.java" line_range="406" />
<code_context>
- tag.getValue().isNull() ? null : tag.getValue().asText()));
+ tag.getValue().isNull()
+ ? null
+ : tag.getValue().asString()));
return result;
}
</code_context>
<issue_to_address>
**Malformed tags break filtered listings**
When a taskmaster job's stored `json-input` annotation contains a non-null, non-string scalar in `tags`, `extractTags` calls `asString()` without checking the stored tag value's type, so a non-string scalar in a task's `json-input` annotation throws while `TesServiceImpl.listTasks` evaluates a tag filter; the whole listing fails instead of returning matching tasks.
Check each non-null tag value is a string before converting it, and handle other types without aborting the listing.
</issue_to_address>
### Comment 4
<location path="src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesInput.java" line_range="151" />
<code_context>
- @ApiModelProperty(
- value = "FILE if left out or null; directories need DIRECTORY",
- allowableValues = "DIRECTORY,FILE")
+ @Schema(description = "FILE if left out or null; directories need DIRECTORY", requiredMode = Schema.RequiredMode.NOT_REQUIRED, allowableValues = {"DIRECTORY", "FILE"})
@NotNull
</code_context>
<issue_to_address>
**OpenAPI rejects valid null types**
When a client uses the OpenAPI 3 schema to validate or generate a request containing `inputs[].type: null` or `outputs[].type: null`, the generated OpenAPI schemas list only `FILE` and `DIRECTORY` and omit `type` from `required`, but do not allow `null`; generated clients that validate against the schema reject requests the API accepts.
Represent null as an allowed schema value for both type fields while keeping them optional.
Also at `src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesOutput.java:252`.
</issue_to_address>
### Comment 5
<location path="src/test/java/uk/ac/ebi/tsc/tesk/config/security/UserDetailsServiceTest.java" line_range="15-16" />
<code_context>
+
+ @Test
+ public void noAuth_hasNoUsers() {
+ assertThat(new NoAuthConfiguration().userDetailsService().loadUserByUsername("user"))
+ .isNull();
+ }
+
</code_context>
<issue_to_address>
**Default user store can remain**
When either configuration's `@Bean` registration is removed, `noAuth_hasNoUsers` and `auth_hasNoUsers` construct configuration objects directly (lines 15 and 21–24), so both still pass if `@Bean` is removed and Spring Boot's generated in-memory user store is no longer replaced.
Load each profile's configuration in a Spring test context and assert that the registered `UserDetailsService` replaces Boot's generated in-memory service.
Also at `src/test/java/uk/ac/ebi/tsc/tesk/config/security/UserDetailsServiceTest.java:23-24`.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 5 findings to address first, the security scan did not finish, and a regression in the migrated security matchers or filter-chain setup could let unauthenticated requests reach task endpoints or expose task data; reverting restores the prior checks, but access that occurred while the change was live cannot be undone.
Blocking findings: pom.xml:17, src/main/java/uk/ac/ebi/tsc/tesk/config/security/CustomAuthenticationEntryPoint.java:134, src/main/java/uk/ac/ebi/tsc/tesk/k8s/convert/TesKubernetesConverter.java:406, src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesInput.java:151, src/test/java/uk/ac/ebi/tsc/tesk/config/security/UserDetailsServiceTest.java:16
Jackson 3's asString() refuses objects and arrays, which Jackson 2's asText() read as "": a tag value of that kind in a stored task (only possible if changed by hand) failed the listing of tasks. Read them as "" again. Tests from the automated review: the user store without users in the application contexts of both profiles, and the higher quality among equally specific types on a 401. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Linked issuesChecked at commit 6fd5e9b #166 build: replace Springfox with springdoc · 3 of 3 met
#168 build: move to Spring Boot 3.5 · 2 of 3 met
#169 build: move to Spring Boot 4 · 4 of 4 met
#170 build: clear the Trivy ignore list · 2 of 2 met
|
Summary
Moves TESK API from Spring Boot 2.7 (end of life) to Spring Boot 4.1 (Spring Framework 7, Spring Security 7, Jackson 3, Hibernate Validator 9, Tomcat 11), in one step instead of the planned detour through 3.5, for release 2.0.0. No behaviour changes apart from those of the framework, which
docs/upgrading.mdlists:javax->jakarta; the lambda DSL of Spring Security 7 withauthorizeHttpRequests(error dispatches stay permitted, as before) and@EnableMethodSecurity; thenoauthprofile without Spring Security's defaults, as withWebSecurityConfigurerAdapter(true)before.spring.jackson.use-jackson2-defaults=true, so that the JSON of the API and of the tasks stored in Kubernetes stays as it was. Messages of400for unreadable JSON are worded by Jackson 3 (e.g.Unrecognized propertyinstead ofUnrecognized field)./v3/api-docs;/v2/api-docsforwards there for one release (ApiDocsAliasController, tested inApiDocsAliasIT, deprecation in the upgrade notes). The generated models and API stubs carry OpenAPI 3 annotations; the description keepsdocker_login/docker_passwrite-only and the field names of TES. The Swagger UI stays off by default (404 for all its paths); its configuration moves from/swagger-resourcesto/v3/api-docs/swagger-config; the OAuth2 settings of the Swagger UI keep working.*/*(Spring 7 refuses to sort them).UrlHandlerFilter, ordered after Spring Security, so that security sees the original path; tests for both profiles).useSpringBoot3/useJakartaEefor thegenerate-swaggerprofile (stubs not regenerated; checked that the profile runs and that its output compiles apart from the documented manual parts)..trivyignore.yamlis empty (file kept with header and example); Dependabot no longer holds back Spring Security, WireMock and the generator (Spring Boot majors stay ignored).Part of #66 (left open for #163, google-java-format update, and #167, JUnit 5).
Closes #166
Closes #168
Closes #169
Closes #170
Verification
./mvnw clean verify(Java 21): BUILD SUCCESS, 18561 unit tests and 121 integration tests pass, "All coverage checks have been met" (100% lines and branches)../mvnw spotless:check checkstyle:checkon Java 8, as the CI jobLint: passes. actionlint and shellcheck on the workflows: pass.mkdocs build --strict: passes.Dockerfile; theCheck responsesstep of the CI jobsmoke, extracted fromci.ymland run verbatim against it: passes (both profiles: service info,/v3/api-docsand/v2/api-docswithopenapi: 3.x, Swagger UI paths 404 when off and 200 when on,401withauth, invalidTESK_API_SWAGGER_UI_ENABLEDrefused)..trivyignore.yaml(critical and high, fixed only, as in CI): no findings. 25 medium findings remain, all in glibc of the Ubuntu base image.CI passed, Codecov patch and project). CodeQL: two CSRF alerts dismissed (see Decisions).Declined review findings
Fixed from the local reviews: TRS lookups had lost their 10 s timeouts (now explicit), more than 50 accepted media types gave 500 instead of 401,
/v3/api-docs.yamlneeded a token, plus cleanups (shared path constants, no inheritance between the Swagger UI conditions, comment placement). Declined:.swagger-codegen-ignoreto.openapi-generator-ignore: the plugin reads the file by its configured name; a rename is unrelated to the framework move.clientIdtest ofSwaggerConfigAuthTest: the client ID's way into the Swagger UI is already checked bySwaggerOAuthClientSecretTest(swagger-initializer.js); the test covers the properties class./v2/api-docswithnoauthin an IT: the smoke test in CI checks it in both profiles; the IT covers the case that matters (auth, no token)./swagger-ui.html: none of them changes behaviour against 1.2.0 (the TRS lookups had the same 10 s timeouts through OkHttp; any number of media types was handled;/swagger-ui.htmlwas never public), so there is nothing to upgrade for.server.use-forward-headers(no-op since Spring Boot 2.2; Kubernetes gets the native strategy by default, unchanged),nullin the schema oftype(not allowed before either, nor in the TES spec), and the skipped Spring Boot 3.5 stage of build: move to Spring Boot 3.5 #168 (an unreleased stepping stone; its content is here on 4.1). Fixed from Sourcery: stored object/array tag values failed listings on Jackson 3, the user store is now checked in both application contexts, and a test pins the quality ordering of media types.SwaggerUiDisabledCondition.isEnabledis package-private and used by both conditions.Decisions
java/spring-disabled-csrf-protection(alerts 506, 507): dismissed as "won't fix" by the maintainer. CSRF was already off ondev; the API is stateless and takes bearer tokens only from the header, without cookies.Open questions
None.
🤖 Generated with Claude Code