Fix new code list with multiple codes failing to save (#878)#894
Open
simonreed wants to merge 1 commit into
Open
Fix new code list with multiple codes failing to save (#878)#894simonreed wants to merge 1 commit into
simonreed wants to merge 1 commit into
Conversation
Frontend: assign code.order in the create path (matching the update path). Backend: replace map.with_index with each_with_index to make intent clear. Guard err.response access with optional chaining so a network error does not raise a secondary TypeError. Adds a backend controller test and a Playwright flow regression test. Also adds fixtures :all to test_helper.rb which was missing, causing all controller/model tests to fail with undefined method 'users'. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.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.
Fixes a bug where creating a new code list with two or more codes in a single submit would fail silently. The create path in CodeListForm.js did not assign
ordervalues to codes before sending to the server, while the update path did. With one code, order collisions don't occur; with two or more codes both lacking order, the server's fallback doesn't reliably produce distinct values in a single transaction.The fix assigns
order = i + 1to every code before both create and update dispatches, removing the asymmetry. A backend controller cleanup replacesmap.with_index(which left nils in the array) witheach_with_indexfor blank-row filtering. A new backend test covers POST-create with two codes and no client-supplied order. A Playwright regression feature file verifies the full flow end-to-end. Save failures now surface a visible error rather than failing silently.Round 2 Changes
Round 1 failed on process only: the PR creation tool exited with an error because it constructed the OAuth token URL incorrectly, resolving to the wrong path. The block-direct-pr.sh hook prohibited any fallback. No code changes were needed in round 2 — the fix corrects the OAuth path resolution in the PR creation tool and adds a flag to specify the correct base branch when project settings lack a default_branch value.
All code was independently verified in round 1: 13 backend test runs, 0 failures, Playwright flow green, brakeman clean.
Verification failures from round 1