learningequality / learningequality/studio

`request.user.is_anonymous` checks in some Viewsets might be dead code

Open
#2,463 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

DEV: backend TAG: tech update / debt
Dominant language
Python
Stars
191
Forks
307
Avg merge
5d 6h
Merged PRs (30d)
10

Description

Summary

See this diff for places in the Viewset code where there is a branch in the get_queryset method (or somewhere else) that guards against not request.user.is_anonymous, even though the main View class has a IsAuthenticated permissions class.

So it's not clear if this code is necessary since the View should be immediately returning an error and not even get to the point where it makes a query to fulfill the request.

I also added another note about the CustomPermissions class (which is used in the Django options as a default permissions class) that looks like dead code as well, since there are no Views that I can find that leave their permissions_classes field empty, but that might requirer a closer look to confirm.

Category

Select one: Tech debt

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the linked diff and the Viewset methods that check request.user.is_anonymous, especially get_queryset, then inspect the CustomPermissions class and Django's default permission configuration. Trace whether each branch can execute before IsAuthenticated rejects the request. Done means every suspected path is confirmed necessary or removed, with the relevant project checks passing.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.