Skip to content

Show an error instead of a traceback for invalid llm schemas dsl input - #1908

Open
Caezarr wants to merge 1 commit into
simonw:mainfrom
Caezarr:schemas-dsl-error
Open

Caezarr wants to merge 1 commit into
simonw:mainfrom
Caezarr:schemas-dsl-error

Conversation

@Caezarr

@Caezarr Caezarr commented Nov 19, 2026

Copy link
Copy Markdown

llm schemas dsl with invalid input ends with a full Python traceback:

$ llm schemas dsl 'name, age integer'
Traceback (most recent call last):
  ...
ValueError: Invalid schema DSL: unknown type 'integer' for field 'age'

schema_dsl() raises ValueError for an unknown type, a field with no name or a duplicate field. --schema and --schema-multi already turn that into a CLI error (#1647), but the schemas dsl command calls schema_dsl() directly and doesn't catch it. It now reports the same message as a normal CLI error:

$ llm schemas dsl 'name, age integer'
Error: Invalid schema DSL: unknown type 'integer' for field 'age'

Added test_schemas_dsl_invalid covering the three errors; it fails without the change. pytest (1601 passed), black --check, ruff check, mypy llm and the cog --check from CI pass locally.

This branch has not been deployed

No deployments
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.

1 participant