Skip to content

fix: recurse through pasted block data to replace static paths - #36723

Merged
ChrisChV merged 3 commits into
openedx:masterfrom
open-craft:jill/fix-paste-unit-with-files
May 22, 2025
Merged

fix: recurse through pasted block data to replace static paths#36723
ChrisChV merged 3 commits into
openedx:masterfrom
open-craft:jill/fix-paste-unit-with-files

Conversation

@pomegranited

@pomegranited pomegranited commented May 15, 2025

Copy link
Copy Markdown
Contributor

Description

This PR fixes an error that is triggered when trying to copy/pasting Drag-and-drop block into Courses.

When a block is pasted into a Course or Library, we perform a search/replace on block's data to replace any old static URLs with their new path. Ordinary blocks like HTML and Video have a simple string of data where static URLs may live, but DnDv2 blocks have a dict of data which can contain other dicts and lists of strings that need to be modified. Other XBlocks may have similarly complex structures, and so this fix will resolve them as well.

This fixes the issue by recursing into the data structure to locate all the strings where replacements may need to be made.

This fix helps Course Authors use content staging in their Courses.

Supporting information

No github issue -- discovered this bug while doing something else.
Private-ref: FAL-4080

Testing instructions

  1. Import the demo course
  2. Copy the Unit from Module 3 > Intermediate Assessment Tools > Drag-and-Drop (or just the DnDv2 block by itself) into the content staging clipboard.
  3. Paste the copied unit into a Library.
  4. Copy the Library Unit into a new Course.
    Ensure that the pasted Drag and Drop block shows all its images correctly, and that these images were all copied into the new course.

Deadline

ASAP -- will need to backport to Teak.

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels May 15, 2025
@openedx-webhooks

openedx-webhooks commented May 15, 2025

Copy link
Copy Markdown

Thanks for the pull request, @pomegranited!

This repository is currently maintained by @openedx/wg-maintenance-edx-platform.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

e.g when the block is a drag-and-drop block, the data is a complex dict
with nested data that may also contain static file URLs.
@pomegranited
pomegranited force-pushed the jill/fix-paste-unit-with-files branch from 30e709d to 8efa5a5 Compare May 15, 2025 07:21
@pomegranited
pomegranited marked this pull request as ready for review May 15, 2025 07:24
@mphilbrick211 mphilbrick211 added the needs reviewer assigned PR needs to be (re-)assigned a new reviewer label May 15, 2025
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions May 15, 2025

@rpenido rpenido left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍
Thank you for your work, @pomegranited!
Beautiful solution!

  • I tested this using the instructions from the PR
  • I read through the code
  • I checked for accessibility issues
  • Includes documentation

@ChrisChV ChrisChV left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good 👍

@ChrisChV
ChrisChV enabled auto-merge (squash) May 21, 2025 23:55
@ChrisChV
ChrisChV merged commit 21399b4 into openedx:master May 22, 2025
@ChrisChV
ChrisChV deleted the jill/fix-paste-unit-with-files branch May 22, 2025 00:17
@github-project-automation github-project-automation Bot moved this from Ready for Review to Done in Contributions May 22, 2025
@openedx-webhooks openedx-webhooks removed the needs reviewer assigned PR needs to be (re-)assigned a new reviewer label May 22, 2025
@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

pomegranited added a commit to open-craft/openedx-platform that referenced this pull request May 22, 2025
…dx#36723)

Fixes an error that is triggered when trying to copy/pasting Drag-and-drop block into Courses.

When a block is pasted into a Course or Library, we perform a search/replace on block's data to replace any old static URLs with their new path. Ordinary blocks like HTML and Video have a simple string of data where static URLs may live, but DnDv2 blocks have a dict of data which can contain other dicts and lists of strings that need to be modified. Other XBlocks may have similarly complex structures, and so this fix will resolve them as well.

This fixes the issue by recursing into the data structure to locate all the strings where replacements may need to be made.

This fix helps Course Authors use content staging in their Courses.

(cherry picked from commit 21399b4)
ChrisChV pushed a commit that referenced this pull request May 22, 2025
… (#36773)

Fixes an error that is triggered when trying to copy/pasting Drag-and-drop block into Courses.

When a block is pasted into a Course or Library, we perform a search/replace on block's data to replace any old static URLs with their new path. Ordinary blocks like HTML and Video have a simple string of data where static URLs may live, but DnDv2 blocks have a dict of data which can contain other dicts and lists of strings that need to be modified. Other XBlocks may have similarly complex structures, and so this fix will resolve them as well.

This fixes the issue by recursing into the data structure to locate all the strings where replacements may need to be made.

This fix helps Course Authors use content staging in their Courses.

(cherry picked from commit 21399b4)
marlonkeating pushed a commit that referenced this pull request Jul 15, 2025
Fixes an error that is triggered when trying to copy/pasting Drag-and-drop block into Courses.

When a block is pasted into a Course or Library, we perform a search/replace on block's data to replace any old static URLs with their new path. Ordinary blocks like HTML and Video have a simple string of data where static URLs may live, but DnDv2 blocks have a dict of data which can contain other dicts and lists of strings that need to be modified. Other XBlocks may have similarly complex structures, and so this fix will resolve them as well.

This fixes the issue by recursing into the data structure to locate all the strings where replacements may need to be made.

This fix helps Course Authors use content staging in their Courses.
Copilot AI pushed a commit to AhtishamShahid/edx-platform that referenced this pull request Mar 4, 2026
…dx#36723) (openedx#36773)

Fixes an error that is triggered when trying to copy/pasting Drag-and-drop block into Courses.

When a block is pasted into a Course or Library, we perform a search/replace on block's data to replace any old static URLs with their new path. Ordinary blocks like HTML and Video have a simple string of data where static URLs may live, but DnDv2 blocks have a dict of data which can contain other dicts and lists of strings that need to be modified. Other XBlocks may have similarly complex structures, and so this fix will resolve them as well.

This fixes the issue by recursing into the data structure to locate all the strings where replacements may need to be made.

This fix helps Course Authors use content staging in their Courses.

(cherry picked from commit 21399b4)
(cherry picked from commit 8bcdfbf)
Copilot AI pushed a commit to AhtishamShahid/edx-platform that referenced this pull request Mar 4, 2026
…dx#36723) (openedx#36773)

Fixes an error that is triggered when trying to copy/pasting Drag-and-drop block into Courses.

When a block is pasted into a Course or Library, we perform a search/replace on block's data to replace any old static URLs with their new path. Ordinary blocks like HTML and Video have a simple string of data where static URLs may live, but DnDv2 blocks have a dict of data which can contain other dicts and lists of strings that need to be modified. Other XBlocks may have similarly complex structures, and so this fix will resolve them as well.

This fixes the issue by recursing into the data structure to locate all the strings where replacements may need to be made.

This fix helps Course Authors use content staging in their Courses.

(cherry picked from commit 21399b4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants