Raise when :router given to use Phoenix.VerifiedRoutes is not a literal - #6806
Open
novaugust wants to merge 4 commits into
Open
Raise when :router given to use Phoenix.VerifiedRoutes is not a literal#6806novaugust wants to merge 4 commits into
:router given to use Phoenix.VerifiedRoutes is not a literal#6806novaugust wants to merge 4 commits into
Conversation
novaugust
commented
Aug 26, 2026
:router given to use Phoenix.VerifiedRoutes is not a literal:router given to use Phoenix.VerifiedRoutes is not a literal
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.
What is this
WarnRaises when non-literal modules are passed for the:routeroption with VerifiedRoutesBackground
In an effort to avoid compilation-cycles, we had code where the VerifiedRoutes router was being created dynamically.
While it technically worked, that could create scenarios where it looked like routes were being enforced/verified at compile time when they really weren't, as the compiler was not aware of the dependencies between the modules.
I've since updated our code to not have that problem, but thought it might be worth having a warning come out of Phoenix itself.
There's already existing code that does similar work within the private
build_routefunction:phoenix/lib/phoenix/verified_routes.ex
Lines 932 to 943 in cb69bb8
I'm wondering if the intention there was the same as what i have here, save that that missed cases like this where the value could be expanded into a module.
Example
Given a dynamically resolved router:
in our setup, I could get this buggy behaviour due to the missing explicit compile-time dependency:
~p"/my_path"routeAssisted by: claude-sonnet-5