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:
@@ -35,6 +35,15 @@ pub enum Error {
|
||||
excerpt: String,
|
||||
},
|
||||
|
||||
/// A non-2xx response: the server's message, plus any per-field
|
||||
/// validation errors.
|
||||
///
|
||||
/// **A missing record is `400`, not `404`.** Invoice Ninja's exception
|
||||
/// handler maps Laravel's `ModelNotFoundException` to a 400 whose message
|
||||
/// is `No query results for model [App\Models\Client].`, and reserves 404
|
||||
/// for a route that does not exist or a method that route does not
|
||||
/// support. Matching on 404 to mean "not found" will never fire — match
|
||||
/// the status together with the message.
|
||||
#[error("api returned {status}: {message}")]
|
||||
Api {
|
||||
status: reqwest::StatusCode,
|
||||
|
||||
Reference in New Issue
Block a user