Organization endpoints don't validate their request bodies

Open
#6,396 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
django, python
Domain
api, backend, testing

Research direction

Read contentcuration/contentcuration/viewsets/channel.py around ChannelViewSet.organization_migration and contentcuration/contentcuration/views/users.py around send_organization_invitation_email, then review the serializer strategy in issue #6387. Add regression tests for a non-object JSON body and an unsupported organization share_mode; done means both endpoints return 400 for invalid bodies, and invalid invitations are not created.

Written by the indexing model from the issue text.

Description

DEV: backend

Overview

The organization endpoints on unstable don't validate their request bodies. A malformed body returns 500, and an organization invitation can be sent with any share_mode, which then fails with a 500 when the invitee accepts.

Complexity: Low
Target branch: unstable

Context

Both inputs below were reproduced:

The Change
  • Both views should validate their bodies with DRF serializers, following the strategy in #6387.
  • send_organization_invitation_email should accept only the share modes _accept_organization_invitation handles for organizations: VIEW_ACCESS, EDIT_ACCESS and ADMIN_ACCESS.
Acceptance Criteria
General
  • organization_migration returns 400 for a body that isn't a JSON object.
  • send_organization_invitation_email returns 400 and creates no invitation for a share_mode outside VIEW_ACCESS, EDIT_ACCESS and ADMIN_ACCESS, or a malformed body.
Testing
  • Each input in Context has a regression test.

AI usage

I scoped the audit and chose the validation strategy in #6387. Claude Code found and reproduced these failures and drafted this issue.

Dominant language
JavaScript
Stars
214
Forks
327
Avg merge
17h 5m
Merged PRs (30d)
25

Getting set up

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.

More from learningequality/studio

All issues in learningequality/studio

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.