Skip to content

fix: accept a null type of inputs and outputs - #150

Merged
uniqueg merged 5 commits into
devfrom
fix/146-null-io-type
Nov 12, 2026
Merged

uniqueg merged 5 commits into
devfrom
fix/146-null-io-type

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Summary

TES 1.1 makes the type of inputs and outputs optional. A left-out type was FILE already (field default); an explicit "type": null was refused with 400 Bad Request, because TesFileType.fromValue returns null for it and @NotNull fails.

  • TesInput and TesOutput read type from JSON through a private @JsonSetter("type") String setter that calls the new TesFileType.fromJson: null is FILE, known values map to the enum, unknown or empty values stay null and are refused by validation with 400, as before.
    • Why not @JsonSetter(nulls = Nulls.SKIP) or an enum deserializer with getNullValue: Jackson 2.18 sends nulls returned by a deserializer (unknown values) through the same null handling as JSON null, so both would turn unknown values into FILE. Tests caught this.
  • The API description no longer marks type as required and lists DIRECTORY and FILE in the request and response models (the request model's type would otherwise be a plain string, as springfox takes the type from the setter).
  • docs/api.md ("TES 1.1 fields"): the type is optional; directories still need type: DIRECTORY, as TESK doesn't infer it (that would need tesk-core).

Closes #146

Verification

  • ./mvnw -B spotless:apply clean verify checkstyle:check spotless:check with Temurin 8: all unit and integration tests pass, BUILD SUCCESS.
  • Tests written first and seen failing:
    • TesFileTypeDefaultTest: missing, null, DIRECTORY, unknown and empty types of inputs and outputs.
    • TasksApiControllerTest.createTask_valid_nullInputAndOutputTypes (valid_tasks/null_io_types.json: null and left-out types through the application's mapper); createTask_invalid_inputs/_outputs now also cover an empty input type and an unknown output type.
    • ApiDocsFileTypeTest: type is optional with both values in TesInputReq/Res and TesOutputReq/Res.
  • Patch coverage of the changed main lines (JaCoCo, unit + IT): 100%.
  • mkdocs build --strict: passes.
  • CI: all checks pass on 44f37ba (with the Sourcery fix), including codecov/patch and codecov/project.

Declined review findings

  • Release and upgrade notes: written at release prep; the PRs since 1.2.0 added none.
  • The private JSON setter is repeated in both models (a few lines; Jackson needs one per class); the rule itself lives in TesFileType.fromJson.
  • A DIRECTORY case through the controller: covered by TesFileTypeDefaultTest and the existing valid tasks. (The controller test now uses an ArgumentCaptor, from Sourcery.)

Open questions

None.

🤖 Generated with Claude Code

https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV

Summary by Sourcery

Support optional TES 1.1 input and output types while retaining validation for invalid values.

New Features:

  • Accept omitted or explicitly null input and output types as FILE in accordance with TES 1.1.

Bug Fixes:

  • Preserve validation errors for unknown or empty input and output types instead of treating them as FILE.

Enhancements:

  • Update API schemas to mark input and output types as optional and document the DIRECTORY and FILE values.

Documentation:

  • Document optional input and output types, their FILE default, and the requirement to explicitly specify DIRECTORY.

Tests:

  • Add coverage for JSON type defaults, invalid values, controller behavior, and generated API documentation.

uniqueg and others added 2 commits November 12, 2026 10:41
TES 1.1 makes the type of inputs and outputs optional. A left-out type
was FILE already; an explicit null was refused with 400 Bad Request.

- The models read the type from JSON through a String setter: null is
  FILE, known values map to the enum, and unknown or empty values stay
  null and are refused by validation as before. (Jackson sends nulls
  returned by a deserializer through the same null handling as JSON
  null, so this can't be done in the enum's deserializer.)
- The API description no longer marks the type as required and lists
  its two values in requests and responses.
- docs/api.md: directories still need type DIRECTORY; TESK doesn't
  infer it.

Closes #146

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
From the review: TesInput and TesOutput call TesFileType.fromJson
instead of repeating the rule. Tests cover an empty input type and an
unknown output type on the 400 path, and types left out next to null
ones at controller level; the API-docs test uses API_DOCS_URL.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
@sourcery-ai

sourcery-ai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

API

Default omitted or explicit-null input and output types to FILE while preserving validation of unknown values, and expose the optional enum values in the API models.

  • src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesFileType.java L43-56
  • src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesInput.java L5, L153-155, L168-173
  • src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesOutput.java L6, L216-218, L231-236

Documentation

Document the optional input and output type, its FILE default, and the need to specify DIRECTORY explicitly.

  • docs/api.md L97-100

Tests

Verify the API documentation marks type optional and lists its supported values for request and response models.

  • src/test/java/uk/ac/ebi/tsc/tesk/config/swagger/ApiDocsFileTypeTest.java L1-45

Cover omitted, null, valid, unknown, and empty types at model and controller levels, including rejection through validation.

  • src/test/java/uk/ac/ebi/tsc/tesk/tes/api/TasksApiControllerTest.java L27-30, L58-61, L481-512 (+3 small edits)
  • src/test/java/uk/ac/ebi/tsc/tesk/tes/model/TesFileTypeDefaultTest.java L1-52
  • src/test/resources/invalid_tasks/inputs/empty_type.json L1-18
  • src/test/resources/invalid_tasks/outputs/wrong_type.json L1-18
  • src/test/resources/valid_tasks/null_io_types.json L1-30

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.98%. Comparing base (f974342) to head (b87881c).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #150      +/-   ##
==========================================
- Coverage   73.07%   72.98%   -0.10%     
==========================================
  Files          70       70              
  Lines        2941     2946       +5     
  Branches      330      330              
==========================================
+ Hits         2149     2150       +1     
- Misses        651      655       +4     
  Partials      141      141              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@uniqueg
uniqueg marked this pull request as ready for review November 12, 2026 09:53
@sourcery-ai

sourcery-ai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Linked issues

Checked at commit b87881c

#146 fix: accept a null type of inputs and outputs · 3 of 3 met

# Requirement Status Notes
1 Treat a null input or output type like a missing type (FILE) ✅ Met Both models use a JSON setter that maps null to FILE; tests cover null and omitted types for each.
2 Document that directories need type: DIRECTORY ✅ Met docs/api.md says directories still need type: DIRECTORY because TESK does not infer it.
3 Add tests for both models ✅ Met TesFileTypeDefaultTest covers TesInput and TesOutput, including null, omitted, DIRECTORY, unknown, and empty types.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/test/java/uk/ac/ebi/tsc/tesk/tes/api/TasksApiControllerTest.java" line_range="489-495" />
<code_context>
+                .createTask(
+                        argThat(
+                                task ->
+                                        task.getInputs().stream()
+                                                        .allMatch(
+                                                                input ->
+                                                                        input.getType()
</code_context>
<issue_to_address>
**Empty collections satisfy type check**

When the application mapper supplies empty input and output lists for the request, the `allMatch` checks return true for empty input and output lists, so `verify` accepts the task without proving any types were mapped to `FILE`. The test passes even though the request’s inputs and outputs were discarded.

Assert that the lists contain the expected number of entries before checking that their types are `FILE`.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 1 finding to address first, and a task that previously failed validation when an input or output type was explicitly null can now run with that path treated as a FILE. If the path was actually intended to be a directory, execution may transfer the wrong artifact to or from the configured URL; reverting would stop future cases but would not undo artifacts already written.

Blocking findings: src/test/java/uk/ac/ebi/tsc/tesk/tes/api/TasksApiControllerTest.java:495


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

From Sourcery: allMatch passes for empty lists. The controller test
captures the task and compares the lists of types (two inputs and two
outputs, FILE each), so dropped entries fail it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sourcery assessment

Approved.

# Conflicts:
#	src/test/java/uk/ac/ebi/tsc/tesk/tes/api/TasksApiControllerTest.java
@uniqueg
uniqueg merged commit cfd3cfe into dev Nov 12, 2026
25 checks passed
@uniqueg
uniqueg deleted the fix/146-null-io-type branch November 12, 2026 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: accept a null type of inputs and outputs

1 participant