Skip to content

fix: handle Channel.DoesNotExist in remove_self#5769

Open
ashnaaseth2325-oss wants to merge 1 commit intolearningequality:unstablefrom
ashnaaseth2325-oss:fix/channel-does-not-exist-remove-self
Open

fix: handle Channel.DoesNotExist in remove_self#5769
ashnaaseth2325-oss wants to merge 1 commit intolearningequality:unstablefrom
ashnaaseth2325-oss:fix/channel-does-not-exist-remove-self

Conversation

@ashnaaseth2325-oss
Copy link

SUMMARY

This PR fixes an unhandled Channel.DoesNotExist exception in the remove_self view that caused a 500 error for invalid channel_id. It ensures a proper 404 response is returned instead.
Primary changes are in contentcuration/contentcuration/viewsets/user.py.


FIX

  • Code (before → after)
# Before
channel = Channel.objects.get(id=channel_id)

# After
try:
    channel = Channel.objects.get(id=channel_id)
except Channel.DoesNotExist:
    return HttpResponseNotFound(...)

RESULT

  • Invalid channel_id now returns 404 Not Found instead of 500
  • Prevents runtime crashes from uncaught exceptions
  • Makes the existing error handling path reachable
  • No impact on valid request flow

Signed-off-by: ashnaaseth2325-oss <ashnaaseth2325@gmail.com>
@learning-equality-bot
Copy link

👋 Thanks for contributing!

We will assign a reviewer within the next two weeks. In the meantime, please ensure that:

  • You ran pre-commit locally
  • All issue requirements are satisfied
  • The contribution is aligned with our Contributing guidelines. Pay extra attention to Using generative AI. Pull requests that don't follow the guidelines will be closed.

We'll be in touch! 😊

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.

1 participant