Handle deleted workflows and snapshot failures in API#4965
Open
jmtdev0 wants to merge 1 commit into
Open
Conversation
19a687b to
bdc62bd
Compare
Contributor
Author
|
Follow-up on CircleCI lint After inspecting the failed lint job 98087, I made a small formatting-only adjustment to the new regression test. The test logic and production behavior are unchanged. The new pipeline 98090 confirms that the formatting issue is resolved. The other PR-specific checks also pass: The remaining lint job 98092 fails only on This PR was developed by Codex with jmtdev0's supervision. |
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.
Description
This PR fixes the workflows REST API so failures from
save_workflow/3arereturned as proper HTTP responses instead of falling through as raw tuples and
crashing the Phoenix controller.
The controller now:
404 Not Foundwhen a workflow is soft-deleted between fetch andsave.
500 Internal Server Errorwhen saving the workflow snapshot fails.falsesnapshot failure value and the clearer:snapshot_failedvalue introduced by the related save-workflow work.It also adds regression coverage and an Unreleased changelog entry.
Closes #4960
Validation steps
mix test test/lightning_web/controllers/api/workflows_controller_test.exs.57 tests, 0 failures.404witherrors: ["Not Found"].500with a clearsnapshot error instead of crashing the controller.
Validated with:
mix test test/lightning_web/controllers/api/workflows_controller_test.exsmix compile --warnings-as-errorsgit diff --checkAdditional notes for the reviewer
maybe_handle_error/3, whichreturned these unhandled failures unchanged. Phoenix controllers must return
a connection or a valid response, so the raw tuple caused the request to
crash.
save_workflow/3implementation returnsfalsefor a snapshotfailure, while the clearer
:snapshot_failedatom is used by the relatedchange discussed in PR AI-First Starting UX: Build from scratch #4918. Handling both keeps this fix correct for the
current branch and forward-compatible with that naming improvement.
through the same
maybe_handle_error/3clauses. Triggering a snapshotcollision during creation would require artificial database setup and would
test a different failure mechanism rather than a different controller
contract. The two PATCH tests cover both distinct error responses directly.
resources return
404, while a snapshot persistence failure returns500.AI Usage
Please disclose whether you've used AI anywhere in this PR (it's cool, we just
want to know!):
You can read more details in our
Responsible AI Policy
Pre-submission checklist
/reviewwith Claude Code)
(e.g.,
:owner,:admin,:editor,:viewer)Not applicable: this PR only changes error handling after the existing authorization checks.
This PR was developed by Codex with jmtdev0's supervision.