fix(repository): replace peek_result panic with InfrastructureError#326
Open
SAY-5 wants to merge 1 commit intoaixigo:masterfrom
Open
fix(repository): replace peek_result panic with InfrastructureError#326SAY-5 wants to merge 1 commit intoaixigo:masterfrom
SAY-5 wants to merge 1 commit intoaixigo:masterfrom
Conversation
peek_result panicked via unreachable!() when the database returned a row whose status is 'done' but whose result_success and result_error columns (and the merged-with task's columns) are all NULL. The incident in aixigo#307 shows this state does occur in production — the operator's database had ten such rows after a deployment failure — and the unreachable!() reduced PREvant to a panicking task fetcher. Surface the corrupt row as an AppsError::InfrastructureError that identifies the affected status_id so the caller can return a 500 and recover, leaving the row in the database for an operator to inspect or repair instead of taking the whole API down. Closes aixigo#307. Signed-off-by: SAY-5 <say.apm35@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #307.
peek_result(api/src/apps/repository.rs) panics viaunreachable!()when the database returns a row whosestatus = 'done'but whoseresult_successandresult_errorcolumns (and the merged-with task's columns) are all NULL. The incident in #307 shows this state does occur in production — the operator's database had ten such rows:The
unreachable!()therefore reduced PREvant to a panicking task fetcher whenever a corrupt row was peeked.Fix
Replace the unreachable arm with
Err(AppsError::InfrastructureError { error: ... })so the caller can return a 500, the operator can inspect/repair the row, and the rest of the system keeps running:The error variant is already exported and is the closest semantic match for "the task ran but its outcome wasn't persisted".
Test plan
cargo build -p prevant— passesapp_taskrow) that the API now returns 500 with the new error message instead of crashing the worker.