Skip to content

SG-43269 Improve core swap diagnostics with version mismatch detection#1099

Open
carlos-villavicencio-adsk wants to merge 6 commits into
masterfrom
ticket/SG-43269_core_backwards_compatibility
Open

SG-43269 Improve core swap diagnostics with version mismatch detection#1099
carlos-villavicencio-adsk wants to merge 6 commits into
masterfrom
ticket/SG-43269_core_backwards_compatibility

Conversation

@carlos-villavicencio-adsk
Copy link
Copy Markdown
Contributor

@carlos-villavicencio-adsk carlos-villavicencio-adsk commented May 20, 2026

What

When Toolkit performs a core swap (e.g. from the bundled Desktop core to a site or project config core), it now:

  • Logs both the current core version and the target core version at swap time, making it immediately clear which two versions are involved.
  • On any import failure during the swap, detects whether the target core is older than the currently running core and, if so, logs an actionable error message pointing to the tk-core release notes.

Why

Core swap failures are notoriously hard to diagnose because the previous log line only printed the target path, with no version context. When a customer upgrades FPT Desktop (which ships a newer bundled tk-core) while their site or project config still pins an older core, the swap can fail with cryptic ModuleNotFoundError or ImportError tracebacks that give no hint about the root cause.

With this change, support and engineers can immediately see entries like:

CoreImportHandler (version v0.23.8): Begin swapping core to .../install/core/python (version v0.22.4)
...
Core version mismatch: v0.22.4 might be older than v0.23.8. Please check the release notes for breaking changes: 
https://github.com/shotgunsoftware/tk-core/releases

This cuts down diagnostic time significantly for the class of issues where a project or site config is pinned to an outdated core that is incompatible with the currently running version.

Changes

  • bootstrap/import_handler.py - reads site and target core versions before the swap and includes them in the existing debug log; adds a bare except after the import tank block that checks for a version downgrade and logs an exception-level message with a link to the release notes before re-raising.
  • pipelineconfig_utils.py - re-exports is_version_older via # noqa: F401 so callers can import it from the public pipelineconfig_utils surface rather than the internal util.version module.

Testing

Reproduced locally with FPT Desktop v3.0.0 (bundled tk-core v0.23.8) and a project pipeline config pinned to tk-core v0.22.4. The new log lines appear correctly before the failure, and the version mismatch message is emitted with a stack trace attached.

This comment was marked as resolved.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.46%. Comparing base (aac02b8) to head (999312e).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1099      +/-   ##
==========================================
+ Coverage   79.42%   79.46%   +0.03%     
==========================================
  Files         198      198              
  Lines       20753    20778      +25     
==========================================
+ Hits        16484    16511      +27     
+ Misses       4269     4267       -2     
Flag Coverage Δ
Linux 78.92% <100.00%> (+0.02%) ⬆️
Python-3.10 79.27% <100.00%> (+0.02%) ⬆️
Python-3.11 79.17% <100.00%> (+0.02%) ⬆️
Python-3.13 79.17% <100.00%> (+0.02%) ⬆️
Python-3.9 79.25% <100.00%> (+0.03%) ⬆️
Windows 78.96% <100.00%> (+0.03%) ⬆️
macOS 78.93% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@carlos-villavicencio-adsk carlos-villavicencio-adsk requested a review from a team May 21, 2026 00:30
@carlos-villavicencio-adsk
Copy link
Copy Markdown
Contributor Author

Logs before:

image
2026-05-21 10:46:30,611 [24816 DEBUG sgtk.ext.tkimp11f140d78259459bb4b47a89b43a7abf.tk_desktop.site_communication] [PROXY] ...core swap complete.
2026-05-21 10:46:30,612 [24816 DEBUG sgtk.ext.tkimp11f140d78259459bb4b47a89b43a7abf.tk_desktop.site_communication] [PROXY] running explicit 'import tank' to re-initialize new core...
2026-05-21 10:46:30,828 [24816 ERROR sgtk.env.site.tk-desktop.tkimp11f140d78259459bb4b47a89b43a7abf.tk_desktop.desktop_window] Error

No module named 'tank_vendor.six.moves'

Traceback (most recent call last):
  File "C:\Program Files\Shotgun\Resources\Desktop\Python\bundle_cache\app_store\tk-desktop\v2.8.5\python\utils\bootstrap_utilities.py", line 216, in start_engine
    return manager.bootstrap_engine("tk-desktop", self._project)
           ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\villavc\AppData\Roaming\Shotgun\asset-management.staging.shotguncloud.com\sitec496.basic.desktop\cfg\install\core\python\tank\bootstrap\manager.py", line 487, in bootstrap_engine
    tk = self._bootstrap_sgtk(engine_name, entity)
  File "C:\Users\villavc\AppData\Roaming\Shotgun\asset-management.staging.shotguncloud.com\sitec496.basic.desktop\cfg\install\core\python\tank\bootstrap\manager.py", line 1100, in _bootstrap_sgtk
    tk, user = config.get_tk_instance(self._sg_user)
               ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "C:\Users\villavc\AppData\Roaming\Shotgun\asset-management.staging.shotguncloud.com\sitec496.basic.desktop\cfg\install\core\python\tank\bootstrap\configuration.py", line 127, in get_tk_instance
    if self._swap_core_if_needed(python_core_path):
       ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "C:\Users\villavc\AppData\Roaming\Shotgun\asset-management.staging.shotguncloud.com\sitec496.basic.desktop\cfg\install\core\python\tank\bootstrap\configuration.py", line 220, in _swap_core_if_needed
    CoreImportHandler.swap_core(target_python_core_path)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\villavc\AppData\Roaming\Shotgun\asset-management.staging.shotguncloud.com\sitec496.basic.desktop\cfg\install\core\python\tank\bootstrap\import_handler.py", line 92, in swap_core
    import tank
  File "C:\Users\villavc\AppData\Roaming\Shotgun\asset-management.staging.shotguncloud.com\p454c34.basic.desktop\cfg\install\core\python\tank\__init__.py", line 112, in <module>
    from . import authentication
  File "C:\Users\villavc\AppData\Roaming\Shotgun\asset-management.staging.shotguncloud.com\p454c34.basic.desktop\cfg\install\core\python\tank\authentication\__init__.py", line 35, in <module>
    from .shotgun_authenticator import ShotgunAuthenticator
  File "C:\Users\villavc\AppData\Roaming\Shotgun\asset-management.staging.shotguncloud.com\p454c34.basic.desktop\cfg\install\core\python\tank\authentication\shotgun_authenticator.py", line 13, in <module>
    from .sso_saml2 import has_sso_info_in_cookies, has_unified_login_flow_info_in_cookies
  File "C:\Users\villavc\AppData\Roaming\Shotgun\asset-management.staging.shotguncloud.com\p454c34.basic.desktop\cfg\install\core\python\tank\authentication\sso_saml2\__init__.py", line 15, in <module>
    from .core.errors import (  # noqa
    ...<7 lines>...
    )
  File "C:\Users\villavc\AppData\Roaming\Shotgun\asset-management.staging.shotguncloud.com\p454c34.basic.desktop\cfg\install\core\python\tank\authentication\sso_saml2\core\__init__.py", line 15, in <module>
    from .sso_saml2_core import SsoSaml2Core  # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\villavc\AppData\Roaming\Shotgun\asset-management.staging.shotguncloud.com\p454c34.basic.desktop\cfg\install\core\python\tank\authentication\sso_saml2\core\sso_saml2_core.py", line 52, in <module>
    from tank_vendor.six.moves.urllib.parse import urlencode
ModuleNotFoundError: No module named 'tank_vendor.six.moves'

Logs now:

image
2026-05-21 11:07:02,355 [30600 DEBUG sgtk.ext.tkimp02aade7ee27c41bb852f6c2968b7bcf4.tk_desktop.site_communication] [PROXY] ...core swap complete.
2026-05-21 11:07:02,358 [30600 DEBUG sgtk.ext.tkimp02aade7ee27c41bb852f6c2968b7bcf4.tk_desktop.site_communication] [PROXY] running explicit 'import tank' to re-initialize new core...
2026-05-21 11:07:02,677 [30600 ERROR sgtk.ext.tkimp02aade7ee27c41bb852f6c2968b7bcf4.tk_desktop.site_communication] [PROXY] Core version mismatch: v0.22.4 might be older than HEAD. Please check the release notes for breaking changes: https://github.com/shotgunsoftware/tk-core/releases
2026-05-21 11:07:02,705 [30600 ERROR sgtk.env.site.tk-desktop.tkimp02aade7ee27c41bb852f6c2968b7bcf4.tk_desktop.desktop_window] Error

Core version mismatch: v0.22.4 might be older than HEAD. Please check the release notes for breaking changes: https://github.com/shotgunsoftware/tk-core/releases

Traceback (most recent call last):
  File "C:\Users\villavc\AppData\Roaming\Shotgun\asset-management.staging.shotguncloud.com\sitec496.basic.desktop\cfg\install\core\python\tank\bootstrap\import_handler.py", line 101, in swap_core
    import tank
  File "C:\Users\villavc\AppData\Roaming\Shotgun\asset-management.staging.shotguncloud.com\p454c34.basic.desktop\cfg\install\core\python\tank\__init__.py", line 112, in <module>
    from . import authentication
  File "C:\Users\villavc\AppData\Roaming\Shotgun\asset-management.staging.shotguncloud.com\p454c34.basic.desktop\cfg\install\core\python\tank\authentication\__init__.py", line 35, in <module>
    from .shotgun_authenticator import ShotgunAuthenticator
  File "C:\Users\villavc\AppData\Roaming\Shotgun\asset-management.staging.shotguncloud.com\p454c34.basic.desktop\cfg\install\core\python\tank\authentication\shotgun_authenticator.py", line 13, in <module>
    from .sso_saml2 import has_sso_info_in_cookies, has_unified_login_flow_info_in_cookies
  File "C:\Users\villavc\AppData\Roaming\Shotgun\asset-management.staging.shotguncloud.com\p454c34.basic.desktop\cfg\install\core\python\tank\authentication\sso_saml2\__init__.py", line 15, in <module>
    from .core.errors import (  # noqa
    ...<7 lines>...
    )
  File "C:\Users\villavc\AppData\Roaming\Shotgun\asset-management.staging.shotguncloud.com\p454c34.basic.desktop\cfg\install\core\python\tank\authentication\sso_saml2\core\__init__.py", line 15, in <module>
    from .sso_saml2_core import SsoSaml2Core  # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\villavc\AppData\Roaming\Shotgun\asset-management.staging.shotguncloud.com\p454c34.basic.desktop\cfg\install\core\python\tank\authentication\sso_saml2\core\sso_saml2_core.py", line 52, in <module>
    from tank_vendor.six.moves.urllib.parse import urlencode
ModuleNotFoundError: No module named 'tank_vendor.six.moves'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\Shotgun\Resources\Desktop\Python\bundle_cache\app_store\tk-desktop\v2.8.5\python\utils\bootstrap_utilities.py", line 216, in start_engine
    return manager.bootstrap_engine("tk-desktop", self._project)
           ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\villavc\AppData\Roaming\Shotgun\asset-management.staging.shotguncloud.com\sitec496.basic.desktop\cfg\install\core\python\tank\bootstrap\manager.py", line 487, in bootstrap_engine
    tk = self._bootstrap_sgtk(engine_name, entity)
  File "C:\Users\villavc\AppData\Roaming\Shotgun\asset-management.staging.shotguncloud.com\sitec496.basic.desktop\cfg\install\core\python\tank\bootstrap\manager.py", line 1100, in _bootstrap_sgtk
    tk, user = config.get_tk_instance(self._sg_user)
               ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "C:\Users\villavc\AppData\Roaming\Shotgun\asset-management.staging.shotguncloud.com\sitec496.basic.desktop\cfg\install\core\python\tank\bootstrap\configuration.py", line 127, in get_tk_instance
    if self._swap_core_if_needed(python_core_path):
       ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "C:\Users\villavc\AppData\Roaming\Shotgun\asset-management.staging.shotguncloud.com\sitec496.basic.desktop\cfg\install\core\python\tank\bootstrap\configuration.py", line 220, in _swap_core_if_needed
    CoreImportHandler.swap_core(target_python_core_path)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\villavc\AppData\Roaming\Shotgun\asset-management.staging.shotguncloud.com\sitec496.basic.desktop\cfg\install\core\python\tank\bootstrap\import_handler.py", line 116, in swap_core
    raise ImportError(error_message)
ImportError: Core version mismatch: v0.22.4 might be older than HEAD. Please check the release notes for breaking changes: https://github.com/shotgunsoftware/tk-core/releases

f" changes: https://github.com/shotgunsoftware/tk-core/releases"
)
log.error(error_message)
raise ImportError(error_message)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ℹ️ the raise can go here. If the condition is not evaluated, the error is caught anyway (logged and displayed in the UI)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants