SG-44721 Fix tank core upgrade fails from ≤v0.23.6 to ≥v0.23.7 - #1127
Merged
julien-lang merged 1 commit intoAug 17, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a core-upgrade regression introduced after the tank_vendor dependency-loading overhaul (v0.23.7+), where _core_upgrader.py imported yaml in a way that bypassed tank_vendor/__init__.py, causing ModuleNotFoundError during tank core upgrades.
Changes:
- Adds the local
python/folder (notpython/tank_vendor/) tosys.pathat position 0 so the bundled core code is preferred over any site-packages. - Switches from
import yamltofrom tank_vendor import yamlto ensuretank_vendor’s import hook is registered.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1127 +/- ##
=======================================
Coverage 80.11% 80.11%
=======================================
Files 203 203
Lines 19540 19540
=======================================
Hits 15654 15654
Misses 3886 3886
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
julien-lang
marked this pull request as ready for review
August 7, 2026 13:51
carlos-villavicencio-adsk
approved these changes
Aug 10, 2026
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.
tank corefails withModuleNotFoundError: No module named 'yaml'.Two related cases:
_core_upgrader.pydirectly (e.g.python3 _core_upgrader.py) fails unconditionally on any version >= v0.23.7, including currentmaster- there's no prior process state to mask it.tank coreupgrade command fails specifically when the currently installed core is <= v0.23.6 and the target is >= v0.23.7. Upgrading between two cores that are both already >= v0.23.7 (or both <= v0.23.6) is unaffected - see Root Cause below for why.Root cause
SG-37222 / #996 reworked
tank_vendorthird-party dependency handling starting inv0.23.7: vendored packages moved from flat files underpython/tank_vendor/into zip archives, loaded lazily through asys.meta_pathfinder registered intank_vendor/__init__.py._core_upgrader.pywas never updated for this change. It still addedpython/tank_vendordirectly tosys.pathand did a bareimport yaml, bypassingtank_vendor/__init__.pyentirely, so the finder never registered and the flatyamlmodule it expected no longer existed on disk.tank coreruns as a single, uninterrupted Python process (thetank->tank_cmd.sh->exec $interpreter tank_cmd.pychain replaces the process in place, and the core swap is a plainimport _core_upgraderwithin that process). The currently installed core'score_upgrade.pyalready doesfrom tank_vendor import yamlbefore the swap. If that core is already >= v0.23.7, its vendor package's meta finder resolves this via__import__("yaml"), which as a side effect registers baresys.modules["yaml"]- masking the target's broken bareimport yamlentirely. If the installed core is <= v0.23.6, its pre-reworktank_vendorhas no meta finder, so nothing gets cached, and the target'simport yamlfails for real. This is why the bug only reproduces on the<=v0.23.6 -> >=v0.23.7transition, even though the underlying defect is unconditional.Fix
python/(the parent oftank_vendor) tosys.pathinstead oftank_vendoritself.from tank_vendor import yamlsotank_vendor/__init__.pyruns and registers its lazy-loading finder.sys.path.insert(0, ...)instead ofappendfor consistency with other core scripts.Testing
_core_upgrader.pydirectly; it no longer raisesModuleNotFoundErroron import.master'stank_vendorstructure, matching the reported traceback.tank coreupgrade fromv0.23.6 -> v0.24.0failing without the fix and succeeding with it, and validatedv0.23.7 -> v0.24.0as well; dedicated core-upgrade regression coverage has been added.