You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, when defining routes with Marten, route parameters need to align with the expected handler parameters. If there is a mismatch between the defined route parameter (e.g., id) and the expected parameter (e.g., pk), an error message like the following is raised:
'articles_show' route cannot receive {"pk" => 2} as parameters.
While the error is technically correct, it requires developers to stop and think about the mismatch, especially if the parameter names are similar or common (e.g., id vs. pk). A more descriptive error message could improve the developer experience by explicitly indicating both the expected and received parameters.
Description
Currently, when defining routes with Marten, route parameters need to align with the expected handler parameters. If there is a mismatch between the defined route parameter (e.g.,
id
) and the expected parameter (e.g.,pk
), an error message like the following is raised:While the error is technically correct, it requires developers to stop and think about the mismatch, especially if the parameter names are similar or common (e.g.,
id
vs.pk
). A more descriptive error message could improve the developer experience by explicitly indicating both the expected and received parameters.Scenario
For example, in this route definition:
The handler
ArticlesShowHandler
, expects aid
parameter, but the reversed route usespk
instead. The resulting error is:The message could be more helpful by showing what parameter was expected versus what was provided.
Discussion Points:
Expected Parameters in Error Message:
Should the error message explicitly mention what parameters the handler expects, e.g.:
Clarity for Parameter Mismatch:
How can we make this more intuitive for developers, especially in cases where common parameter names like
id
andpk
are used?Benefits
The text was updated successfully, but these errors were encountered: