fix(core): make me_hotsite url non-capturing so the view does not take a dummy arg#917
Open
SAY-5 wants to merge 1 commit intomemeLab:developfrom
Open
fix(core): make me_hotsite url non-capturing so the view does not take a dummy arg#917SAY-5 wants to merge 1 commit intomemeLab:developfrom
SAY-5 wants to merge 1 commit intomemeLab:developfrom
Conversation
…e a dummy arg
core/urls.py routes /me/ to me_hotsite via
re_path(r"^(me|ME)\/?$", me_hotsite, name="mitologia-extendida")
(me|ME) is a capturing group, so Django passes the matched literal as
a positional arg to the view. The view absorbed it with an underscore:
def me_hotsite(request, _):
return render(request, "core/ME/hotsite.html", {})
The captured value is never used. The fragility is the signature:
anyone who drops the capturing group during a future URL cleanup (or
turns it into a named path converter) breaks the view with
TypeError: me_hotsite() missing 1 required positional argument: '_'.
Same thing happens the other way: if me_hotsite is ever reused from a
pattern without a capture, it will crash.
Switch the regex to a non-capturing group and drop the unused arg from
the view. Behaviour is unchanged for both /me/ and /ME/ (matched
strings are no longer passed, but they weren't doing anything).
Fixes memeLab#851
Signed-off-by: SAY-5 <SAY-5@users.noreply.github.com>
Member
ReviewVerdict: ✅ Correct fix.
Duplicate: Same fix in #928. Generated by Claude Code |
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
core/urls.pyroutes/me/and/ME/tome_hotsitevia are_pathwith a capturing group:Because the group is capturing, Django passes the matched string (
"me"or"ME") as a positional arg to the view. The view swallows it with an underscore:The captured value is never used. The fragility is the signature: anyone cleaning up the URL (dropping the capture, converting to
(?:me|ME), switching topath(...), or reusingme_hotsitefrom a pattern without capture) immediately breaks the view withTypeError: me_hotsite() missing 1 required positional argument: '_'. The two sides are coupled for no functional reason.Fix
urls.py: capture → non-capturing group(?:me|ME).static_views.py: drop the unused second arg from the view signature.Both
/me/and/ME/continue to match and render the same page. The captured string was never consulted, so no behaviour changes.Fixes #851