fix: move BlockKey and derived_key to avoid cyclical import #34051
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Problem
After we merged this PR:
This stack trace began popping up in logs:
Although the trace doesn't make it obvious, the root cause was the new imports of
derived_key
andBlockKey
into xmodule/library_content_block.py. Those new imports come from xmodule/modulestore/store_utilities.py, which runsXBlock.load_classes()
at the module level, which fails because we are still in the process of loading xmodule/library_content_block (so, a cyclical import).Strangely, this cyclical import didn't crash the server or cause any static analysis to fail. In the interest of removing log noise and avoiding unknown buggy behavior, though, we'd like to break this import cycle.
Solution
We move both
derived_key
andBlockKey
to xmodule/util/keys.py. We could potentially move that file to opaque-keys eventually, depending on how well we think that those concepts generalize.Also:
Supporting information
None
Testing instructions
None
Deadline
ASAP--blocks #33511
Other information
None