ADORSYS-GIS / ADORSYS-GIS/lightbridge-authz
[Task]: NULL cost survives as null (f64 → Option<f64>)
- Ngôn ngữ chính
- Rust
- Star
- 0
- Fork
- 1
- Merge trung bình
- 7 giờ 7 phút
- Pull request đã merge (30 ngày)
- 237
Mô tả
Parent: #586 (Per-grain query APIs)
### Summary
Fix the NULL money bug: `UsageSeriesPoint.total_cost` must survive serialization as `null`, never `0.0` (governance#188).
### The bug
`crates/lightbridge-authz-usage/src/repo.rs:269`:
```rust
total_cost: row.total_cost.unwrap_or(0.0),
```
This collapses "unknown cost" into "$0.00". "I don't know what it cost" is not the same as "it was free."
### What to change
1. **`UsageSeriesPoint.total_cost`**: `f64` → `Option` in `crates/lightbridge-authz-usage/src/models/mod.rs:291`
2. **`repo.rs:269`**: remove the `unwrap_or(0.0)` — keep the `Option`
3. **Every new grain point struct** (`ExecutionSeriesPoint`, `DayFactSeriesPoint`): cost fields declared as `Option` (or `Option` for micro-USD BIGINT columns)
### Wire impact
`total_cost` changes from `number` to `number | null` in the JSON response. Existing callers that deserialize as `f64` will break on `null`. This is a deliberate, tested breaking change per governance#188.
### Cross-repo coordination
`converse-frontends` must be notified — the `total_cost` field changes from `number` to `number | null`. Feature-flag the frontend change if needed.
### Tests
- Existing `query_usage` test: seed a row with NULL cost → assert response has `null`, not `0.0`
- New grain tests (Tickets B/C/D): same pattern per grain
- `spend_query_it_tests` must pass unchanged (they already use `Option` for spend)
### Source of truth
- governance#188 — NULL cost must survive to the wire
- `docs/plans/0586-per-grain-query-apis-analysis.md` — AC 5
### Verification evidence
To be attached on the implementing PR.
Hướng dẫn đóng góp
Hướng nghiên cứu
Start with crates/lightbridge-authz-usage/src/models/mod.rs:291 and repo.rs:269, then read the existing query_usage test and spend_query_it_tests. Check the per-grain point structs and the tests described for Tickets B/C/D. Done means NULL costs serialize as null for each grain, the tests pass, and converse-frontends is notified of the breaking wire change.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- rust
- Lĩnh vực
- api, backend, database
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Sôi nổi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 35/100