Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

feat: add no-request uri fallback #265

Merged
merged 3 commits into from
Jun 29, 2023

Conversation

connorhaugh
Copy link
Contributor

Description

I ran into the following issue:

I’m building out a management command to import V1 content Libraries into V2 content libraries. I’m using import_blocks_create_task which works 99% of the way for V1 libraries.
I’ve run into an interesting conundrum. I can get all the data from V1 libs without issue. I can even make a library block which contains that data.
The import, however fails, because upon creation, it returns the metadata object about the block it just created using get_library_block (which makes sense).
that call makes a call to blockstore, obviously, which makes a bunch of calls, one of which is to _build_absolute_uri which pulls the request from CRUM middleware and builds the URI from that.
The issue is, there is no request in the CRUM middleware because this is a management command, not a user request…
consequently, I get AttributeError: 'NoneType' object has no attribute 'build_absolute_uri'

THe way I fixed this, is by changing _build_absolute_uri so that it can fall back to settings.LMS_ROOT_URL to build the absolute URI if there is no current request.

@connorhaugh connorhaugh requested review from bszabo and a team June 29, 2023 12:50
@connorhaugh connorhaugh merged commit fe49557 into master Jun 29, 2023
@connorhaugh connorhaugh deleted the feat--add-no-request-uri-fallback branch June 29, 2023 14:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants