fix(brief): make GET /brief a pure query, 404 when absent (RB-23)
GET /brief allocated a row on first call (BriefStore.GetOrCreate) — the one endpoint in the backend where a read performed a persisted write. The FE retries GETs automatically, so a transient failure could enter the create path more than once; a lock prevented a duplicate row, but the safety depended on the lock, not on the endpoint being a query. Split GetOrCreate into Get (a pure query) and the already-existing ResetAndCreate (POST /brief/reset owns creation). GET /brief now 404s when the owner has no brief yet. GET /brief/preview used GetOrCreate too, so it gets the same Get + 404 treatment, forced by the split. RB-22 already made BriefStore.load() on the FE tolerate a 404 by calling reset() once; this ticket is what makes that branch live. Updated the brief/preview/org-template backend tests that assumed GET seeded a brief on first call to create one explicitly first, and added a test that GET 404s and writes no row without the fix (verified red beforehand). Regenerated the API client (npm run gen:api). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -21,7 +21,7 @@ tested where._
|
||||
Every bullet below is a real test name from the suite — an `it()` title (frontend) or a test
|
||||
method name (backend), read as a sentence. Nothing here is hand-written prose: this page
|
||||
**is** the suite, reshaped for a business reader. 467 frontend behaviours across
|
||||
9 contexts; 237 backend behaviours across 41 test
|
||||
9 contexts; 238 backend behaviours across 41 test
|
||||
classes.
|
||||
|
||||
## Frontend (by context)
|
||||
@@ -999,7 +999,8 @@ classes.
|
||||
|
||||
### BriefEndpointTests
|
||||
|
||||
- Get creates a draft with expected sections locked and empty
|
||||
- Get returns 404 and writes no row when no brief exists for the owner
|
||||
- SeedBrief creates a draft with expected sections locked and empty
|
||||
- Get offers only global and arts scoped besluit tagged passages
|
||||
- Get joins the case context with the BIG nummer masked
|
||||
- Reveal returns the unmasked BIG nummer for the drafter with step up
|
||||
|
||||
@@ -1350,6 +1350,10 @@ export class ApiClient {
|
||||
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as BriefViewDto;
|
||||
return result200;
|
||||
});
|
||||
} else if (status === 404) {
|
||||
return response.text().then((_responseText) => {
|
||||
return throwException("Not Found", status, _responseText, _headers);
|
||||
});
|
||||
} else if (status !== 200 && status !== 204) {
|
||||
return response.text().then((_responseText) => {
|
||||
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||
|
||||
Reference in New Issue
Block a user