Fix/controller no methods #471
Merged
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.
Fix error when controller has no mapped methods
Description
This PR fixes an issue in the
getRouteInfofunction insrc/debug.tswhere an error would occur when processing controllers that don't have any mapped methods. The fix ensures thatmethodMetadatais always treated as an array by providing a fallback empty array when it's undefined.Related Issue
No existing issue was found for this bug, but the error occurs when trying to call
.map()on undefinedmethodMetadatafor controllers without HTTP method decorators.Motivation and Context
When using the debug utilities to inspect routes in an application with controllers that don't have any HTTP methods mapped (perhaps they're abstract base controllers or controllers in development), the
getRouteInfofunction would throw an error. This fix makes the function more robust by handling this edge case properly.How Has This Been Tested?
I've added a specific test case in the test suite that verifies the function can handle controllers without any mapped methods. The test creates a container with an empty controller (no HTTP methods) and ensures that
getRouteInforeturns the expected structure with an empty endpoints array for that controller.Types of changes
Checklist: