-
Notifications
You must be signed in to change notification settings - Fork 3.1k
feat: better YAML parsing error reporting #5750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { configYamlSchema } from "../schemas/index.js"; | ||
import { parseConfigYaml } from "./unroll.js"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The import path uses '.js' extension but the actual file has '.ts' extension. This will cause module resolution issues at runtime since the file being imported is 'unroll.ts' not 'unroll.js'.
|
||
|
||
|
||
|
||
describe("config.yaml validation", () => { | ||
it("parses valid config YAML", () => { | ||
const yaml = ` | ||
name: Local Assistant | ||
version: 1.0.0 | ||
schema: v1 | ||
|
||
models: | ||
- name: granite3.3:8b | ||
provider: ollama | ||
model: granite3.3:8b | ||
roles: | ||
- autocomplete | ||
- chat | ||
|
||
- name: nomic-embed-text | ||
provider: ollama | ||
model: nomic-embed-text:latest | ||
roles: | ||
- embed | ||
|
||
context: | ||
- provider: code | ||
- provider: docs | ||
- provider: diff | ||
- provider: terminal | ||
- provider: problems | ||
- provider: folder | ||
- provider: codebase | ||
- provider: clipboard | ||
|
||
rules: | ||
- name: Angry Teenager | ||
rule: always respond like an angry teenager | ||
|
||
docs: | ||
- name: Continue docs | ||
startUrl: https://docs.continue.dev/ | ||
`; | ||
const result = parseConfigYaml(yaml); | ||
expect(result).toMatchObject({ name: "Local Assistant", version: "1.0.0" }); | ||
expect(() => configYamlSchema.parse(result)).not.toThrow(); | ||
}); | ||
|
||
it("throws on invalid YAML", () => { | ||
const yaml = ` | ||
name: Local Assistant | ||
version: 1.0.0 | ||
schema: v1 | ||
|
||
models: [] | ||
|
||
context: | ||
- provider: code | ||
- provider: codebase | ||
|
||
data: | ||
- destination: https://docs.continue.dev/ | ||
`; | ||
|
||
const expectedError = `Failed to parse assistant: | ||
Validation error: Required at \"data[0].name\"; Required at \"data[0].schema\", or Required at \"data[0].uses\"`; | ||
|
||
expect(() => parseConfigYaml(yaml)).toThrow(expectedError); | ||
}); | ||
|
||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The import path uses '.js' extension but the actual file has '.ts' extension. This will cause module resolution issues at runtime since the file being imported is 'index.ts' not 'index.js'.