fix(router): timeentry/export.csv must come before /:id#69
Merged
Conversation
#68 added /v1/timeentry/export.csv but placed the route AFTER the existing /v1/timeentry/:id block. Express tries patterns top-down, so a GET to /v1/timeentry/export.csv matched the :id route first, the intIdParam validator parsed "export.csv" → NaN → 400 with "expected number". The test that asserts 403 on missing authKey was flaking on this path. The export handler was never reached. Mirrors the search-before-:id ordering #64 used for customer. Added a comment block flagging the rule for future contributors. All four timeentry CRUD routes still resolve correctly — they sit AFTER the literals now, which is the correct order. Suite: 261 / 261 + 4 integration skipped (post-fix). Co-Authored-By: Claude Opus 4.7 (1M context) <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.
Hot follow-up to #68. The new
/v1/timeentry/export.csvroute was placed AFTER the existing/v1/timeentry/:idblock, so express matched:id-with-"export.csv" first, intIdParam failed coercion to a number, and the export handler was never reached. The 403-on-missing-authKey test was failing as a result.Reorders so the literal path wins, matching the
search-before-:idconvention already used for/v1/customer/search(#64).Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/