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
{{ message }}
Repository navigation
a viewset's action list gets "head" added to it, but only after being called at least once #9747
We didn't have head set in our actions on a viewset, but head would suddenly appear in a viewset's actions, but seemingly randomly.
This way of filling in head in actions means that before you call a viewset at least once, it will have one set of actions, but afterwards it would have another.
This is surprising to me, and I have a hard time imagining it to be the right solution here. But perhaps I am missing a detail.
I guess the initial idea of changing SimpleRouter and action decorator was the better way to go with. I applied to changes here, it seems fine to me if you're fine with it I can open a PR @browniebroke .
I'm not sure... The OP flags the mutation problem but is not clear on expected behaviour. The current fix makes sure head is never present in the viewset actions, but one could argue that it should always be there
I'm not sure... The OP flags the mutation problem but is not clear on expected behaviour. The current fix makes sure head is never present in the viewset actions, but one could argue that it should always be there
Should the basic flow of behavior change? In this logic, partially yes. What if someone only wants to accept "GET" requests but does not accept "HEAD" requests? I think the current solution addresses this.
Hi! I'd be interested in working on this. It looks like the actions mapping is mutated inside the request closure, so view.actions changes after the first request. Would moving the implicit HEAD mapping to as_view() initialization (without mutating the caller-provided mapping) be an acceptable direction?
Activity
browniebroke commentedon Jul 25, 2025
Seems like this behaviour is due to what was done in #7223 for #6196
Do you have a suggestion on how to fix that?
Sajadrahimi commentedon Aug 25, 2025
I guess the initial idea of changing
SimpleRouterandactiondecorator was the better way to go with. I applied to changes here, it seems fine to me if you're fine with it I can open a PR @browniebroke .auvipy commentedon Dec 14, 2025
you can open a pr for review
mag123c commentedon Dec 18, 2025
Taking this on since no PR has been opened yet.
Fix viewset actions dict being mutated after first request (encode#9747)
Natgho commentedon Mar 2, 2026
This solution seems quite sufficient. It will eliminate mutation-related errors;
#9853 mutation source
browniebroke commentedon Mar 2, 2026
I'm not sure... The OP flags the mutation problem but is not clear on expected behaviour. The current fix makes sure head is never present in the viewset actions, but one could argue that it should always be there
Natgho commentedon Mar 2, 2026
Should the basic flow of behavior change? In this logic, partially yes. What if someone only wants to accept "GET" requests but does not accept "HEAD" requests? I think the current solution addresses this.
EliArn99 commentedon Aug 20, 2026
Hi! I'd be interested in working on this. It looks like the actions mapping is mutated inside the request closure, so view.actions changes after the first request. Would moving the implicit HEAD mapping to as_view() initialization (without mutating the caller-provided mapping) be an acceptable direction?