Improve Router Registration Error#644
Open
TylerPachal wants to merge 3 commits intocommanded:masterfrom
Open
Conversation
TylerPachal
commented
Feb 4, 2026
Comment on lines
-669
to
-670
| defp parse_opts([{:to, aggregate_or_handler} | opts], result) do | ||
| case Keyword.pop(opts, :aggregate) do |
Contributor
Author
There was a problem hiding this comment.
Annotation: This was problematic. This assume that the :to was always before the :aggregate, and would break when that was not the case. There was also a funny interaction with the :function option because of how it was set to either :execute or :handle (so again, depending on order, you could lose a user-provide value for :function).
The fix is to pull out the options we need so they can be compared together, instead of looping over them sequentially.
TylerPachal
commented
Feb 4, 2026
Comment on lines
+681
to
+683
| case {to, aggregate} do | ||
| {nil, _aggregate} -> | ||
| raise "dispatch missing required parameter: :to" |
Contributor
Author
There was a problem hiding this comment.
Annotation: The raise is the actual improvement to #644. See the unit test for an example.
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.
If you forgot to include the required
:tooption indispatch(...)during your router registration you would get an unhelpful error (as noted in #422). This PR fixes that, so that a more helpful error is returned.Additionally, while trying to replicate this I found another bug with the registration arguments: if the
:tooption was not the first option in the list, things would break. I've addressed that bug here as well because it was in the same part of the code.For this PR, the first commit was adding the new tests (which failed), and the second commit is the changes to get the tests passing.
Closes #422