fix(tasks): handle the canonical TasksStateUpdate wrapper from GET /tasks#85
Merged
Merged
Conversation
…asks
The OpenAPI spec defines the response as
`TasksStateUpdate { tasks: [TaskStateUpdate] }`, but `get_all_tasks`
only matched on a bare JSON array and silently returned `Vec::new()`
for any other shape — including the wrapper the API actually returns.
The result: every call returned no tasks, with no error surfaced.
This commit:
- Introduces a private `TasksStateUpdate` matching the spec.
- Rewrites `get_all_tasks` to accept the wrapper, the empty `{}` /
`null` responses (legitimate "no tasks" replies), and a bare array
(legacy compatibility), erroring loudly on anything else via
`CloudError::JsonError`. No more silent fallback to empty.
- Updates the `mock_tasks_list` test-support helper to wrap its
payload in the canonical shape so test consumers exercise the same
path real callers will.
- Replaces the previously dead-letter test
`tests/tasks_tests.rs::test_get_all_tasks` (which mounted a mock
but never invoked the handler) with four focused tests covering
the wrapper, empty-object, bare-array, and unknown-shape cases.
Refs #74 #64 (canonical task models — `TaskStateUpdate` dedup is the
follow-on)
Closes #74
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
get_all_tasksnow correctly handles the OpenAPI-defined response shapeTasksStateUpdate { tasks: [TaskStateUpdate] }. Previously the handler only matched on a bare JSON array, so every real-API response fell through to a silentVec::new().{},null) and the legacy bare-array shape (backward compatibility).CloudError::JsonErrorinstead of silently returning empty — so a future schema change is loud, not invisible.mock_tasks_listinsrc/testing/server.rsnow wraps its payload in the canonical shape so consumers of the test-support feature exercise the same code path as real callers.test_get_all_tasks(which mounted a wiremock expectation but never called the handler) with four focused tests covering wrapper, empty-object, bare-array, and unknown-shape cases.Why
Issue #74 documents the bug. Static analysis against
cloud_openapi.jsonand the existing test fixture both confirm the wire shape; the previous handler couldn't decode it.This PR is scoped to
get_all_tasksonly. The broaderTaskStateUpdatededuplication across the crate is tracked in #64.Test plan
cargo fmt --all -- --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspace— all pass (full suite)mock_tasks_listchange verified against the existingtest_mock_tasks_list_with_handlerinsidesrc/testing/server.rsCloses #74
Refs #64 (task type dedup)