Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion sqlmesh/core/config/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,14 @@ def load_config_from_paths(


def load_config_from_yaml(path: Path) -> t.Dict[str, t.Any]:
return yaml_load(path)
content = yaml_load(path)
if not isinstance(content, dict):
raise ConfigError(
f"Invalid YAML configuration: expected a dictionary but got {type(content).__name__}. "
f"Please check the YAML syntax in your config file.",
location=path,
)
return content


def load_config_from_python_module(
Expand Down
42 changes: 42 additions & 0 deletions vscode/extension/tests/broken_project.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,48 @@ const setup = async (tempDir: string) => {
}

test.describe('Bad config.py/config.yaml file issues', () => {
test('sqlmesh init, then corrupted config.yaml, bad yaml', async ({
page,
sharedCodeServer,
}) => {
const tempDir = await fs.mkdtemp(
path.join(os.tmpdir(), 'vscode-test-tcloud-'),
)
await setup(tempDir)
await createPythonInterpreterSettingsSpecifier(tempDir)

const configYamlPath = path.join(tempDir, 'config.yaml')
// Write an invalid YAML to config.yaml
await fs.writeFile(configYamlPath, 'invalid_yaml; asdfasudfy')

await page.goto(
`http://127.0.0.1:${sharedCodeServer.codeServerPort}/?folder=${tempDir}`,
)
await page.waitForLoadState('networkidle')

// Open full_model.sql model
await page
.getByRole('treeitem', { name: 'models', exact: true })
.locator('a')
.click()
await page
.getByRole('treeitem', { name: 'full_model.sql', exact: true })
.locator('a')
.click()

// Wait for the error to appear
await page.waitForSelector('text=Error creating context')

// Open the problems view
await runCommand(page, 'View: Focus Problems')

// Asser that the error is present in the problems view
await page
.getByText('Invalid YAML configuration:')
.first()
.isVisible({ timeout: 5_000 })
})

test('sqlmesh init, then corrupted config.yaml, bad parameters', async ({
page,
sharedCodeServer,
Expand Down