Skip to content

fix: return 404 in changeOrder when entry doesn't exist#174

Open
jakebromberg wants to merge 2 commits intomainfrom
fix/16-changeorder-null-check
Open

fix: return 404 in changeOrder when entry doesn't exist#174
jakebromberg wants to merge 2 commits intomainfrom
fix/16-changeorder-null-check

Conversation

@jakebromberg
Copy link
Member

Summary

  • changeOrder crashed with TypeError: Cannot read properties of undefined (reading 'play_order') when called with a non-existent entry_id, because the query result was accessed at [0] without checking for an empty array.
  • Now checks if the select query returns no rows and throws WxycError(404) for a clean error response.
  • Added unit test covering the missing-entry case.

Test plan

  • Unit test: flowsheet.changeOrder.test.ts — mocks db.transaction with a trx returning empty array, asserts WxycError with statusCode: 404
  • Full unit suite passes (121 tests)

Made with Cursor

Jake Bromberg and others added 2 commits March 2, 2026 12:40
Accessing [0].play_order on an empty result crashed with TypeError.
Now throws WxycError(404) for a clean error response.

Co-authored-by: Cursor <cursoragent@cursor.com>
@jakebromberg jakebromberg force-pushed the fix/16-changeorder-null-check branch from c9fb2ac to 73fa156 Compare March 2, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants