openedx / openedx/openedx-platform

Bug: deleting a v2 library that ever held a container returns 500

Open
#39,117 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug help wanted
Dominant language
Python
Stars
8.2k
Forks
4.4k
Avg merge
6d 18h
Merged PRs (30d)
42

Description

Where: DELETE /api/libraries/v2/<lib>/ (content_libraries/rest_api/libraries.py
deleteapi/libraries.py delete_library) on Tutor main (edx-platform master e2e8edf73f).

What happens: a library that only ever held components deletes cleanly
(200 {}, then 404). A library that has had a unit/subsection/section, or a
publish with side effects, answers 500 {"error": "The Studio servers encountered an error"}; the CMS log shows django.db.models.deletion.RestrictedError: Cannot delete some instances of model 'LearningPackage' because they are referenced through restricted foreign keys: 'EntityListRow.entity', 'DraftSideEffect.cause', 'DraftSideEffect.effect', 'PublishSideEffect.cause', 'PublishSideEffect.effect'.

Expected: Probably a descriptive 400 error

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 at content_libraries/rest_api/libraries.py delete and follow its call to api/libraries.py delete_library. Reproduce deletion for a library that held a unit, subsection, section, or publish side effects, then inspect how the RestrictedError is handled. Done means the endpoint returns a descriptive 400 instead of the current 500.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.