From 00e57a21a809a11c3af90fa8a2051aac50bbd088 Mon Sep 17 00:00:00 2001 From: Nicolas Gorga <62995075+NicolasGorga@users.noreply.github.com> Date: Thu, 11 Dec 2025 09:44:49 -0300 Subject: [PATCH] fix(framework): Prevent registering express handler for disabled routes (#14236) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary **What** — What changes are introduced in this PR? Avoid registering express handlers for routes that have been disabled via `defineFileConfig`. **Why** — Why are these changes relevant or necessary? When middlewares are defined, disabled routes satisfying the matcher will be registered in express routes with no handler (since this is correctly skipped). This will cause, for example, for routes that have `validateAndTransformBody` defined, for the middleware to be registered. When the body doesn't match the validator, instead of the expected 404, we would get a 400, since the route is registered in the express application (even though it doesn't have a corresponding handler). **How** — How have these changes been implemented? Added a new `#isRouteFileDisabled` method to `ApiLoader` that prevents a middleware to be registered in the express application if the route was disabled. **Testing** — How have these changes been tested, or how can the reviewer test the feature? Integration tests. --- ## Examples Provide examples or code snippets that demonstrate how this feature works, or how it can be used in practice. This helps with documentation and ensures maintainers can quickly understand and verify the change. ```ts // Example usage ``` --- ## Checklist Please ensure the following before requesting a review: - [x] I have added a **changeset** for this PR - Every non-breaking change should be marked as a **patch** - To add a changeset, run `yarn changeset` and follow the prompts - [x] The changes are covered by relevant **tests** - [x] I have verified the code works as intended locally - [x] I have linked the related issue(s) if applicable --- ## Additional Context Add any additional context, related issues, or references that might help the reviewer understand this PR.