feat(api): align basin info with stream info#338
Conversation
Greptile SummaryThis PR replaces the single Key changes:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant CLI
participant SDK
participant API Layer
participant Server
CLI->>SDK: list_all_basins(include_deleted=true)
SDK->>API Layer: list_basins(ListBasinsRequest)
API Layer->>Server: HTTP GET /basins
Server-->>API Layer: JSON { name, scope, created_at, deleted_at, state(deprecated) }
Note over API Layer: Custom Deserialize:<br/>missing created_at → now_utc()<br/>state:deleting + no deleted_at → now_utc()
API Layer-->>SDK: BasinInfo { created_at, deleted_at }
Note over SDK: TryFrom: OffsetDateTime → S2DateTime<br/>filter: include_deleted=true → yield all
SDK-->>CLI: Stream<BasinInfo>
Note over CLI: print_listing_uri(name, deleted_at.is_some())<br/>print_listing_with_created_at for streams
|
| let created_at = created_at.unwrap_or_else(OffsetDateTime::now_utc); | ||
| let deleted_at = match (deleted_at, state) { | ||
| (Some(deleted_at), _) => Some(deleted_at), | ||
| (None, Some(BasinState::Deleting)) => Some(OffsetDateTime::now_utc()), |
There was a problem hiding this comment.
Inaccurate fallback timestamps may mislead users
Both created_at and deleted_at are set to OffsetDateTime::now_utc() when missing from older API responses. While this maintains backward compatibility, it means:
- A basin created weeks ago against an older server will appear to have been created "just now" in the CLI/TUI.
- A basin in
state: deletingwithout a realdeleted_atwill show the current time as its deletion time, not the actual time deletion was requested.
These inaccuracies will be visible to users upgrading their SDK before their server is updated. Consider logging a warning when falling back to now_utc(), or surfacing this via an Option<S2DateTime> to let callers know the value is synthetic.
Prompt To Fix With AI
This is a comment left during a code review.
Path: api/src/v1/basin.rs
Line: 113-116
Comment:
**Inaccurate fallback timestamps may mislead users**
Both `created_at` and `deleted_at` are set to `OffsetDateTime::now_utc()` when missing from older API responses. While this maintains backward compatibility, it means:
- A basin created weeks ago against an older server will appear to have been created "just now" in the CLI/TUI.
- A basin in `state: deleting` without a real `deleted_at` will show the current time as its deletion time, not the actual time deletion was requested.
These inaccuracies will be visible to users upgrading their SDK before their server is updated. Consider logging a warning when falling back to `now_utc()`, or surfacing this via an `Option<S2DateTime>` to let callers know the value is synthetic.
How can I resolve this? If you propose a fix, please make it concise.## 🤖 New release
* `s2-common`: 0.29.0 -> 0.30.0 (⚠ API breaking changes)
* `s2-api`: 0.27.12 -> 0.27.13 (✓ API compatible changes)
* `s2-lite`: 0.29.25 -> 0.29.26 (✓ API compatible changes)
* `s2-sdk`: 0.25.0 -> 0.26.0 (⚠ API breaking changes)
* `s2-cli`: 0.29.25 -> 0.29.26
### ⚠ `s2-common` breaking changes
```text
--- failure constructible_struct_adds_field: externally-constructible struct adds field ---
Description:
A pub struct constructible with a struct literal has a new pub field. Existing struct literals must be updated to include the new field.
ref: https://doc.rust-lang.org/reference/expressions/struct-expr.html
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/constructible_struct_adds_field.ron
Failed in:
field BasinInfo.created_at in /tmp/.tmpC8ehRw/s2/common/src/types/basin.rs:213
field BasinInfo.deleted_at in /tmp/.tmpC8ehRw/s2/common/src/types/basin.rs:214
--- failure enum_missing: pub enum removed or renamed ---
Description:
A publicly-visible enum cannot be imported by its prior path. A `pub use` may have been removed, or the enum itself may have been renamed or removed entirely.
ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/enum_missing.ron
Failed in:
enum s2_common::types::basin::BasinState, previously in file /tmp/.tmpFp6uyJ/s2-common/src/types/basin.rs:203
--- failure struct_pub_field_missing: pub struct's pub field removed or renamed ---
Description:
A publicly-visible struct has at least one public field that is no longer available under its prior name. It may have been renamed or removed entirely.
ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/struct_pub_field_missing.ron
Failed in:
field state of struct BasinInfo, previously in file /tmp/.tmpFp6uyJ/s2-common/src/types/basin.rs:218
```
### ⚠ `s2-sdk` breaking changes
```text
--- failure enum_missing: pub enum removed or renamed ---
Description:
A publicly-visible enum cannot be imported by its prior path. A `pub use` may have been removed, or the enum itself may have been renamed or removed entirely.
ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/enum_missing.ron
Failed in:
enum s2_sdk::types::BasinState, previously in file /tmp/.tmpFp6uyJ/s2-sdk/src/types.rs:1126
--- failure struct_pub_field_missing: pub struct's pub field removed or renamed ---
Description:
A publicly-visible struct has at least one public field that is no longer available under its prior name. It may have been renamed or removed entirely.
ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/struct_pub_field_missing.ron
Failed in:
field state of struct BasinInfo, previously in file /tmp/.tmpFp6uyJ/s2-sdk/src/types.rs:1151
```
<details><summary><i><b>Changelog</b></i></summary><p>
## `s2-common`
<blockquote>
## [0.30.0] - 2026-03-20
### Features
- Align basin info with stream info
([#338](#338))
<!-- generated by git-cliff -->
</blockquote>
## `s2-api`
<blockquote>
## [0.27.13] - 2026-03-20
### Features
- Align basin info with stream info
([#338](#338))
<!-- generated by git-cliff -->
</blockquote>
## `s2-lite`
<blockquote>
## [0.29.26] - 2026-03-20
### Features
- Align basin info with stream info
([#338](#338))
<!-- generated by git-cliff -->
</blockquote>
## `s2-sdk`
<blockquote>
## [0.26.0] - 2026-03-20
### Features
- Align basin info with stream info
([#338](#338))
<!-- generated by git-cliff -->
</blockquote>
## `s2-cli`
<blockquote>
## [0.29.26] - 2026-03-20
### Features
- Align basin info with stream info
([#338](#338))
### Miscellaneous Tasks
- Dep updates ([#340](#340))
<!-- generated by git-cliff -->
</blockquote>
</p></details>
---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).
Co-authored-by: s2-release-plz[bot] <262023388+s2-release-plz[bot]@users.noreply.github.com>
Align basin lifecycle metadata with stream info while keeping the deprecated basin
statefield as a compatibility-only JSON field.created_atanddeleted_atto basin info in the common, API, SDK, and lite layersdeleted_atand stop publishingstatein OpenAPIcreated_atduring deserialize by defaulting it tonow_utc()