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

Open Beginner friendly
#1,545 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
90/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python
Domain
cli

Research direction

Start at schema_dsl() in llm/utils.py around lines 394-395 and reproduce the two examples from the issue. Verify that nameless fields are skipped without raising IndexError, while the existing handling of blank field strings remains unchanged.

Written by the indexing model from the issue text.

Description

Calling schema_dsl() with a field that has no name before the colon crashes with IndexError: list index out of range.

Repro:

from llm.utils import schema_dsl
schema_dsl(':just a description')  # IndexError
schema_dsl('name, :description')   # IndexError

Root cause (llm/utils.py line 394-395): after field.split(":", 1), field_info can be an empty string. field_info.strip().split() then returns [], so field_parts[0] raises IndexError.

The fix is to continue when field_parts is empty, silently skipping the nameless field — consistent with how blank field strings are already filtered out during field splitting.

Dominant language
Python
Stars
12.5k
Forks
998
Avg merge
8d 1h
Merged PRs (30d)
12

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from simonw/llm

All issues in simonw/llm

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.