Fix missing org context in local provider executor thread#1634
Merged
Fix missing org context in local provider executor thread#1634
Conversation
…ety guard local_provider_queue used run_in_executor without setting org context in the thread, unlike remote_provider_queue which already had the fix. Also adds a RuntimeError guard in storage._get_fs_and_root() so missing org context fails fast with a clear message instead of silently resolving to the wrong root.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Member
|
I gotta admit I'm not really sure what is failing on the tests? I must be looking at the wrong thing... |
dadmobile
requested changes
Mar 26, 2026
Member
dadmobile
left a comment
There was a problem hiding this comment.
OK looks like there is a failed test in applications logs from Playwright:
transformerlab-test-1 | File "/app/api/api.py", line 119, in lifespan
transformerlab-test-1 | temp_image_dir = storage.join(await get_workspace_dir(), "temp", "images")
This eventually trickles down to throwing the RuntimeError that this change introduces.
Member
Never mind! (you have to scroll down from the test failure see application logs for Playwright tests) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
local_provider_queue.py:run_in_executorwasn't setting org context in the thread pool thread, solaunch_clustercouldn't see_current_org_idor_current_tfl_storage_uri. Now matches the pattern already used inremote_provider_queue.py.storage.py: Added a guard in_get_fs_and_root()that raisesRuntimeErrorwhen org-scoped storage is enabled but the context var isn't set. This fails fast with a clear message instead of silently resolving to the wrong (unscoped) storage root, which caused confusing "not found" errors.dirs.py: Addedrequire_organization_id()helper that raises if org context is missing, for use as an explicit guard in background tasks and executor threads.Test plan
RuntimeErrorinstead of a silent "not found"cd api && pytestto confirm no regressions