Skip to content

fix(utils): skip nameless fields in schema_dsl instead of raising IndexError#1467

Open
devteamaegis wants to merge 1 commit into
simonw:mainfrom
devteamaegis:fix/indexerror
Open

fix(utils): skip nameless fields in schema_dsl instead of raising IndexError#1467
devteamaegis wants to merge 1 commit into
simonw:mainfrom
devteamaegis:fix/indexerror

Conversation

@devteamaegis
Copy link
Copy Markdown

What's broken

schema_dsl() crashes with IndexError when a field in the DSL string has no name before the colon — for example ':description' or 'name, :description'. This is reachable from the CLI via llm schema dsl ':foo' and from resolve_schema_input when the schema string contains such a field.

Why it happens

After splitting on ':', the left side (field_info) is empty. field_info.strip().split() returns [], so field_parts[0] raises IndexError.

Fix

Added a two-line guard in llm/utils.py after building field_parts: if the list is empty, continue to the next field. Nameless fields are silently skipped, which is the least surprising behavior — the same way a blank field is already skipped by the if field.strip() filter above.

Test

Added test_schema_dsl_empty_field_name in tests/test_utils.py covering both ':just a description' (all-nameless input) and 'name, :no name before colon' (mixed input). All 83 existing tests still pass.

Fixes #1466

…exError

When a field in the DSL string has no name before the colon (e.g. ':description'),
field_info.strip().split() returns [] and field_parts[0] raises IndexError.
Guard with an explicit `if not field_parts: continue` to skip such fields safely.
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.

BUG: schema_dsl() raises IndexError when a field has no name before the colon

1 participant