Skip to content

Conversation

@mag123c
Copy link

@mag123c mag123c commented Dec 18, 2025

Fix the original actions dict passed to ViewSet.as_view() being mutated after the first request.

refs #9747

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where the original actions dictionary passed to ViewSet.as_view() was being mutated after the first request, specifically by adding a 'head' key when a 'get' action was present.

  • Creates a copy of the actions dictionary before any modifications
  • Updates all internal references to use the copied dictionary
  • Adds a regression test to ensure the original dictionary remains unchanged

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
rest_framework/viewsets.py Creates a copy of the actions dict (bound_actions) before modification and uses it for all internal operations, preventing mutation of the original dict
tests/test_viewsets.py Adds a regression test to verify the original actions dict is not mutated after calling as_view() or making requests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants