Expect a 400, not a 404, for a record that is gone
Running the password tier against a disposable 5.13.50 instance for the first time failed its last check. The purge itself was fine — the row really was gone — but the assertion looked for a 404 and the server answers 400. `Handler.php` maps Laravel's `ModelNotFoundException` to a 400 carrying `No query results for model [App\Models\X].` and reserves 404 for a route that does not exist, so a not-found check written against 404 never fires. The assertion now matches the status together with the message, so a 400 raised for some other reason still fails, and `Error::Api` says so for callers, who would otherwise write the same dead branch. Also adds jq to the devshell, which the MSRV recheck in CLAUDE.md pipes through but which was only ever resolving from the host. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -813,9 +813,14 @@ async fn password_checks(client: &InvoiceNinjaClient, report: &mut Report, passw
|
||||
}
|
||||
|
||||
// A purge is permanent, so the record must now be gone, not just flagged.
|
||||
// A missing record answers 400, not 404: the server maps Laravel's
|
||||
// ModelNotFoundException to a 400 and keeps 404 for a missing route. The
|
||||
// message is checked too, so a 400 raised for some other reason fails.
|
||||
match client.get_client(&keep).await {
|
||||
Err(Error::Api { status, .. }) if status.as_u16() == 404 => {
|
||||
report.pass("get_client after purge", "404, the row is gone")
|
||||
Err(Error::Api { status, message, .. })
|
||||
if status.as_u16() == 400 && message.contains("No query results") =>
|
||||
{
|
||||
report.pass("get_client after purge", "400 no query results, the row is gone")
|
||||
}
|
||||
Err(e) => report.fail("get_client after purge", describe(&e)),
|
||||
Ok(_) => report.fail("get_client after purge", "still readable after a purge"),
|
||||
|
||||
Reference in New Issue
Block a user