Skip to content

Fix schema DSL crash on empty field names before :#1471

Open
TheBestVivBoy wants to merge 1 commit into
simonw:mainfrom
TheBestVivBoy:fix/1466-schema-dsl-empty-field
Open

Fix schema DSL crash on empty field names before :#1471
TheBestVivBoy wants to merge 1 commit into
simonw:mainfrom
TheBestVivBoy:fix/1466-schema-dsl-empty-field

Conversation

@TheBestVivBoy
Copy link
Copy Markdown

Summary

Fix schema_dsl() so inputs like :foo or name, :foo raise a validation error instead of crashing with IndexError.

Root cause

When a schema DSL field contains a colon but no field name on the left side, field_info.strip().split() returns an empty list. The existing code indexed field_parts[0], which raised IndexError.

Changes

  • validate that each schema DSL field has a name before :
  • return a clean CLI error for llm schemas dsl
  • return a clean validation error when schema DSL is resolved via --schema
  • add regression tests for the utility and CLI paths

Validation

  • uv run pytest tests/test_utils.py -k schema_dsl
  • uv run pytest tests/test_llm.py -k 'schemas_dsl or schema_using_dsl_invalid_empty_field_name'
  • uv run black llm/utils.py llm/cli.py tests/test_utils.py tests/test_llm.py
  • uv run ruff check llm/utils.py llm/cli.py tests/test_utils.py tests/test_llm.py
  • uv run pytest tests/test_utils.py tests/test_llm.py
  • uv run llm schemas dsl ':foo'
  • uv run llm schemas dsl 'name:text'

@TheBestVivBoy TheBestVivBoy marked this pull request as ready for review June 5, 2026 07:18
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