Skip to content

Commit 7441d63

Browse files
authored
feat(vscode): handle correct config.py with bad config (#4948)
1 parent 461b2a2 commit 7441d63

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

sqlmesh/core/config/loader.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ def load_config_from_python_module(
194194

195195
if config_obj is None or not isinstance(config_obj, Config):
196196
raise ConfigError(
197-
f"Config needs to be a valid object of type sqlmesh.core.config.Config. Found `{config_obj}` instead at '{module_path}'."
197+
f"Config needs to be a valid object of type sqlmesh.core.config.Config. Found `{config_obj}` instead at '{module_path}'.",
198+
module_path,
198199
)
199200

200201
return (

vscode/extension/tests/broken_project.spec.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,4 +358,46 @@ test.describe('Bad config.py/config.yaml file issues', () => {
358358
.first()
359359
.isVisible({ timeout: 5_000 })
360360
})
361+
362+
test('sushi example, correct python, bad config', async ({
363+
page,
364+
sharedCodeServer,
365+
}) => {
366+
const tempDir = await fs.mkdtemp(
367+
path.join(os.tmpdir(), 'vscode-test-tcloud-'),
368+
)
369+
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
370+
await createPythonInterpreterSettingsSpecifier(tempDir)
371+
372+
const configPyPath = path.join(tempDir, 'config.py')
373+
// Write an invalid Python to config.py
374+
await fs.writeFile(configPyPath, 'config = {}')
375+
376+
await page.goto(
377+
`http://127.0.1:${sharedCodeServer.codeServerPort}/?folder=${tempDir}`,
378+
)
379+
await page.waitForLoadState('networkidle')
380+
381+
// Open customers.sql model
382+
await page
383+
.getByRole('treeitem', { name: 'models', exact: true })
384+
.locator('a')
385+
.click()
386+
await page
387+
.getByRole('treeitem', { name: 'customers.sql', exact: true })
388+
.locator('a')
389+
.click()
390+
391+
// Expect the error to appear
392+
await page.waitForSelector('text=Error creating context')
393+
394+
// Open the problems view
395+
await runCommand(page, 'View: Focus Problems')
396+
397+
// Assert that the error is present in the problems view
398+
await page
399+
.getByText('Config needs to be a valid object of type')
400+
.first()
401+
.isVisible({ timeout: 5_000 })
402+
})
361403
})

0 commit comments

Comments
 (0)