Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete resource from everywhere when force_delete is selected #12680

Conversation

thesujai
Copy link
Contributor

@thesujai thesujai commented Sep 25, 2024

Summary

  1. Whenever force_delete is selected, the ContentNodes with same content_id is appended to the node_ids so the content can be deleted from everywhere
  2. Adds a validate method to DeleteChannelValidator so force_delete wont be ignored in the validation process

References

Fixes #12606

Reviewer guidance

Try and replicate this, if it doesn't replicate then we are good to go.


Testing checklist

  • Contributor has fully tested the PR manually
  • If there are any front-end changes, before/after screenshots are included
  • Critical user journeys are covered by Gherkin stories
  • Critical and brittle code paths are covered by unit tests

PR process

  • PR has the correct target branch and milestone
  • PR has 'needs review' or 'work-in-progress' label
  • If PR is ready for review, a reviewer has been added. (Don't use 'Assignees')
  • If this is an important user-facing change, PR or related issue has a 'changelog' label
  • If this includes an internal dependency change, a link to the diff is provided

Reviewer checklist

  • PR is fully functional
  • PR has been tested for accessibility regressions
  • External dependency files were updated if necessary (yarn and pip)
  • Documentation is updated
  • Contributor is in AUTHORS.md

@github-actions github-actions bot added the DEV: backend Python, databases, networking, filesystem... label Sep 25, 2024
Copy link
Member

@nucleogenesis nucleogenesis left a comment

Choose a reason for hiding this comment

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

If the issue is fixable with only the fix to the validator class, then we should avoid adding additional untested code to the command itself. I think that if the force-deletion isn't applied even when the data is successfully passed from front-end through to the creation of the task, then the additional code will be necessary.

Comment on lines 173 to 177
if node_ids and force_delete:
# As we are deleting similar nodes from everywhere
# We need to find the node_ids of all the similar nodes that are not passed from the frontend
# So we will find the content_ids of the nodes that are passed from the frontend and
# then find the node_ids of the nodes that have the same content_id(as content_id is common for all smilar nodes)
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious if maybe this addition isn't necessary - could you try testing it with these changes not applied?

I suspect that the validate method being fixed, which ensures that force_delete is passed to the task, then the feature should work as it did before. I mainly suspect this because it is a feature that used to work but no longer does.

I haven't looked at it closely, but I'd guess that delete_metadata uses the force_delete to the expected effect.

Copy link
Contributor Author

@thesujai thesujai Sep 26, 2024

Choose a reason for hiding this comment

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

That force_delete is behaving differently than my logic here. It deletes the entire channel when a single resource is force_deleted.
See In my Imported Channel. I have some content titled Sample Video that is present in both Topic 1 and Imported Folder(They share the same content_id):
Screenshot from 2024-09-26 11-28-45

So if we force_deleted the Sample Video, only that should have been deleted from both folders. But the entire channel gets deleted:
Screencast from 26-09-24 11:31:00 AM IST.webm

Note: This is only with the changes to DeleteChannelValidator without my change in the deletecontent command. Even with my changes, the behavior remains the same. I

Copy link
Member

Choose a reason for hiding this comment

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

@thesujai thank you for that and apologies for my delay in responding here.

We've stumbled upon a chain of bugs... 😅

This all started when I found that the checkbox to select "force_delete" had a bug, which then led you here to find the bug in the DeleteChannelValidator#validate method, which also led you to find that there is a bug with how we're handling granular deletion as well.


I was expecting the scope of this issue to be more along the lines of what the validator updates fix: the user's selection is passed along to the queuing of the deletion task.

Let's get that fix merged in this PR and fixing the deletion issue itself can be done in a follow-up issue (which you're welcome to take on if you're interested).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reverted! I can try fixing this behavior in a follow-up

Copy link
Member

@nucleogenesis nucleogenesis left a comment

Choose a reason for hiding this comment

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

Let's get the changes to deletecontent reverted here and just merge the fix to the validator - despite now knowing that there is something weird going on when things are actually deleted.

I will make a follow-up issue for that particular problem.

Comment on lines 173 to 177
if node_ids and force_delete:
# As we are deleting similar nodes from everywhere
# We need to find the node_ids of all the similar nodes that are not passed from the frontend
# So we will find the content_ids of the nodes that are passed from the frontend and
# then find the node_ids of the nodes that have the same content_id(as content_id is common for all smilar nodes)
Copy link
Member

Choose a reason for hiding this comment

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

@thesujai thank you for that and apologies for my delay in responding here.

We've stumbled upon a chain of bugs... 😅

This all started when I found that the checkbox to select "force_delete" had a bug, which then led you here to find the bug in the DeleteChannelValidator#validate method, which also led you to find that there is a bug with how we're handling granular deletion as well.


I was expecting the scope of this issue to be more along the lines of what the validator updates fix: the user's selection is passed along to the queuing of the deletion task.

Let's get that fix merged in this PR and fixing the deletion issue itself can be done in a follow-up issue (which you're welcome to take on if you're interested).

@thesujai thesujai force-pushed the delete-resource-from-everywhere branch from 7800af0 to abf7925 Compare October 4, 2024 04:12
@thesujai thesujai requested a review from nucleogenesis October 4, 2024 04:16
Copy link
Member

@nucleogenesis nucleogenesis left a comment

Choose a reason for hiding this comment

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

This LGTM @thesujai -- I'll be making a follow-up issue next week after chatting to @rtibbles about it.

Thank you so much for all of your efforts investigating and working on this @thesujai <3

@rtibbles rtibbles changed the base branch from develop to release-v0.17.x October 23, 2024 15:41
@rtibbles rtibbles force-pushed the delete-resource-from-everywhere branch from abf7925 to 43df183 Compare October 23, 2024 15:58
@rtibbles
Copy link
Member

Just did a quick retarget and rebase, as this is aimed at 0.17 planned patch 2. Will merge once the build completes.

@rtibbles rtibbles merged commit 85dee75 into learningequality:release-v0.17.x Oct 23, 2024
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DEV: backend Python, databases, networking, filesystem...
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Content/Channel Deletion Task: force_delete not forcing deletion
3 participants