adorsys / adorsys/status-list-server
Reject or no-op empty PATCH requests and validate duplicate indices
- Vorherrschende Sprache
- Rust
- Sterne
- 22
- Forks
- 5
- Ø Merge
- 2 T. 11 Std.
- Gemergte PRs (30 T.)
- 47
Beschreibung
## Objective
Prevent empty PATCH requests (`{"statuses": []}`) from incrementing status list versions and inserting duplicate snapshots into history, and reject duplicate indices within a single update payload.
## Context
1. **Empty PATCH redundant writes:** Sending `PATCH /api/v1/status-lists/{list_id}` with `{"statuses": []}` executes a database transaction, advances `updated_at`, increments the version number, and inserts a duplicate snapshot into `status_list_history`. This causes unnecessary database load and bloats history retention tables.
2. **Duplicate index handling:** If an update payload contains duplicate indices (e.g. `[{"index": 0, "status": 0}, {"index": 0, "status": 1}]`), `apply_updates` currently loops through entries sequentially and silently allows the last entry to overwrite earlier ones without validation.
## Deliverables
- [ ] In `src/domain/service.rs` / `update_status.rs`, validate that `statuses` contains at least one update entry; reject empty update requests with `400 Bad Request` ("at least one status update required") or treat as an idempotent no-op without database write.
- [ ] In `src/domain/models/status_list.rs`, validate that all indices in `status_updates` are unique. Reject payloads with duplicate indices with `400 Bad Request`.
- [ ] Add unit and integration tests verifying both checks.
## Acceptance Criteria
- [ ] Empty PATCH requests do not advance the list version or write redundant history rows.
- [ ] Update payloads with duplicate indices are rejected with 400 Bad Request.
## References
- `src/domain/service.rs`
- `src/domain/models/status_list.rs` (lines 239–250)
- Arc review: `arc-review/finalReview/application-functional-bugs/README.md` (PoC 5)
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.