Skip to content

feat(vscode): handling python errors well#4947

Merged
benfdking merged 2 commits intomainfrom
error_in_config_py
Jul 11, 2025
Merged

feat(vscode): handling python errors well#4947
benfdking merged 2 commits intomainfrom
error_in_config_py

Conversation

@benfdking
Copy link
Contributor

@benfdking benfdking commented Jul 9, 2025

No description provided.

@benfdking benfdking force-pushed the error_in_config_py branch 2 times, most recently from 552f8ba to bc0ccd1 Compare July 11, 2025 09:18
@benfdking benfdking marked this pull request as ready for review July 11, 2025 09:19
@benfdking benfdking requested a review from Copilot July 11, 2025 09:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves error handling when loading Python config modules and updates VSCode extension tests to assert the new error messaging.

  • Wraps the Python module import in loader.py in a try/except to raise a descriptive ConfigError on import failures
  • Refactors an existing test to use an explicit expect assertion and adds a new test for invalid config.py in the sushi example

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
vscode/extension/tests/broken_project.spec.ts Refactored test assertion to use expect and added new test scenario
sqlmesh/core/config/loader.py Wrapped Python import in try/except and raises ConfigError on failure
Comments suppressed due to low confidence (2)

sqlmesh/core/config/loader.py:182

  • Update the function docstring to document that ConfigError is raised when the Python module import fails.
def load_config_from_python_module(

sqlmesh/core/config/loader.py:187

  • Add unit tests for load_config_from_python_module to cover the ConfigError path when importing a broken Python file.
    try:

try:
with sys_path(module_path.parent):
config_module = import_python_file(module_path, module_path.parent)
except Exception as e:
Copy link

Copilot AI Jul 11, 2025

Choose a reason for hiding this comment

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

Add exception chaining by raising the new ConfigError with from e (e.g., raise ConfigError(...) from e) to preserve the original traceback.

Copilot uses AI. Check for mistakes.
@benfdking benfdking force-pushed the error_in_config_py branch from bc0ccd1 to 0770a17 Compare July 11, 2025 09:22
Co-authored-by: Themis Valtinos <73662635+themisvaltinos@users.noreply.github.com>
@benfdking benfdking merged commit 3f45d0e into main Jul 11, 2025
27 checks passed
@benfdking benfdking deleted the error_in_config_py branch July 11, 2025 09:57
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