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

fix: render library assets named xblock-... #35910

Merged
merged 5 commits into from
Dec 9, 2024

Conversation

DanielVZ96
Copy link
Contributor

@DanielVZ96 DanielVZ96 commented Nov 21, 2024

Description

Due to static url replacement logic being too open, if you name your static asset "xblock-*", the platform fails to render those images.

image

This PR makes the matching more strict so it lets assets that start with "xblock" to be rendered correctly.

Supporting information

Issue: #35853
Private-Ref: https://tasks.opencraft.com/browse/FAL-3966

Testing instructions

(Make sure you are running the latest frontend-app-authoring changes, and if it still doesn't work try running provisioning)

  1. create a text xblock
  2. upload any image that starts with 'xblock'
  3. assert that once you save, the image gets rendered correctly
    image
    image

Deadline

None

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Nov 21, 2024
@openedx-webhooks
Copy link

Thanks for the pull request, @DanielVZ96!

What's next?

Please work through the following steps to get your changes 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.

🔘 Let us know that your PR is ready for review:

Who will review my changes?

This repository is currently maintained by @openedx/wg-maintenance-edx-platform. Tag them in a comment and let them know that your changes are ready for review.

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.

@bradenmacdonald
Copy link
Contributor

@DanielVZ96 Please fix the quality issue. Also, can you check where else this is used and make sure there are no other regressions?

For example, I know when the drag-and-drop-v2 XBlock is accessed in the LMS (but not in Studio), it loads files like /static/xblock/resources/drag_and_drop_v2/public/js/drag_and_drop.9d2df0fcc9f4.js, so we can check that it's still working. But I don't think those URLs occur in the HTML that is being replaced here. So I'm not sure where else we need to look for any regressions introduced by this change.

@DanielVZ96
Copy link
Contributor Author

DanielVZ96 commented Nov 22, 2024

@bradenmacdonald I tested using both images that start with or without xblock, both in studio and lms.
LMS:
image

image

Authoring:
image

But when I try to copy the url in the authoring MFE I get this error (it's also happening in master so it's not related):
image

Copy link
Contributor

@ChrisChV ChrisChV left a comment

Choose a reason for hiding this comment

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

@DanielVZ96 Looks good 👍 I found an issue (I think it is unrelated). When I upload an image that contains spaces, it appears broken in the preview. You can go ahead and solve it here or create a new task if you want it that way.

https://www.loom.com/share/eff85c72e9b0435bb2d18a33175dbc17

  • I tested this: I followed the testing instructions
  • I read through the code and considered the security, stability and performance implications of the changes.
  • I tested that the UI can be used with a keyboard only (tab order, keyboard controls).
  • Includes tests for bugfixes and/or features added.

@DanielVZ96 DanielVZ96 requested a review from ChrisChV December 3, 2024 01:11
Copy link
Contributor

@ChrisChV ChrisChV left a comment

Choose a reason for hiding this comment

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

@DanielVZ96 Looks good 👍

Comment on lines 454 to 456
# Retry with unquoted path. We don't always unquote because it would not
# be backwards-compatible, but we need to try both.
asset_path = unquote(asset_path)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is to fix assets with a space / %20 in the URL right? What would break if we change to always unquote? I'd prefer to be consistent in how we handle things, and if we can quickly backport this to Sumac, it's not too late for a change like that. Nobody is using it in production yet.

CC @ormsbee

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that we should prioritize simplicity/consistency over compatibility given that nobody's running this in production. My main question is where this translation happens. I would have expected this unquoting to happen higher up in the Django request processing–though I don't remember the specifics of how this is called, so maybe there's something preventing that? I just want to make sure that we're quoting in one place and unquoting in one place during request processing, and that we're not throwing around a bunch of paths that may or may not be quoted at various layers of the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm testing this now. Turns out it still fails to render the images in the LMS. What do you guys think about splitting the whitespace-fixing code into another PR so I can test that further without affecting the "xblock-" fix?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, please open a separate PR for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

alright. i reverted the change and made a separate draft PR here: #35974

@ormsbee
Copy link
Contributor

ormsbee commented Dec 7, 2024

I'll squash + merge this on Monday morning.

@ormsbee ormsbee merged commit eadf5e2 into openedx:master Dec 9, 2024
49 checks passed
@edx-pipeline-bot
Copy link
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
Contributor

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

@edx-pipeline-bot
Copy link
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
Contributor

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

1 similar comment
@edx-pipeline-bot
Copy link
Contributor

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

@edx-pipeline-bot
Copy link
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
Contributor

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

1 similar comment
@edx-pipeline-bot
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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