Skip to content

fix(api): correct static route precedence guidance - #1860

Open
misaelalves99 wants to merge 1 commit into
DouglasNeuroInformatics:mainfrom
misaelalves99:fix/api-1834-static-route-precedence
Open

misaelalves99 wants to merge 1 commit into
DouglasNeuroInformatics:mainfrom
misaelalves99:fix/api-1834-static-route-precedence

Conversation

@misaelalves99

Copy link
Copy Markdown
Contributor

Summary

Closes #1834.

Correct the API documentation's assumption that a parameterized route can shadow a static route registered after it. Fastify prioritizes static routes regardless of declaration order.

Changes

  • Update apps/api/AGENTS.md to document Fastify's static-route precedence.
  • Remove the obsolete perfectionist/sort-classes exemption from InstrumentRecordsController and restore lint-compatible method ordering.
  • Add a Fastify controller regression test verifying that /instrument-records/linear-model reaches the static handler instead of /:id.
  • Add a Playwright HTTP regression test covering the same behavior through the running API.

Validation

Focused local validation against upstream main at a1cdbab8ecabe050ebd2af5c8133bd33dc24baa9:

  • ESLint — passed without autofix.
  • Prettier — passed, check-only.
  • API TypeScript — passed, no emit.
  • Testing TypeScript — passed, no emit.
  • Controller Vitest — 17/17 passed, including the route-precedence regression.
  • Playwright HTTP — 3/3 passed: API setup, route regression and teardown, with no retries.

No dependencies or database schema changes were introduced.

Scope: Full monorepo lint, coverage and E2E suites were not run locally. Focused validation does not imply full CI approval.

@joshunrau joshunrau left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is a clean fix. The corrected paragraph matches find-my-way's documented match order, and the new controller test shows it: the test boots the reordered controller on Fastify, and when I renamed the static route, the request fell through to :id and the test failed as it should.

One change before merge:

  1. Please change the commit type from fix to refactor (or docs). This repo builds CHANGELOG.md and the published changelog page in the user docs from commit subjects. Every fix commit becomes a "Bug Fixes" entry (scripts/changelog.ts:122), and PRs are merged with merge commits, so your commit message lands there as it is. This PR corrects documentation and reorders the controller's methods without changing any behaviour, so it should not appear to users as a bug fix. Rewording the commit to, for example, refactor(api): drop the route-order lint exemption the router never needed (with git commit --amend and a force-push) is enough. Please update the PR title to match.

Reviewed at commit 18226c1.

This branch has not been deployed

No deployments
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.

apps/api AGENTS.md says a :id route shadows a single-segment route, but Fastify matches static routes first

2 participants