fix(utils): skip nameless fields in schema_dsl instead of raising IndexError#1467
Open
devteamaegis wants to merge 1 commit into
Open
fix(utils): skip nameless fields in schema_dsl instead of raising IndexError#1467devteamaegis wants to merge 1 commit into
devteamaegis wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's broken
schema_dsl()crashes withIndexErrorwhen a field in the DSL string has no name before the colon — for example':description'or'name, :description'. This is reachable from the CLI viallm schema dsl ':foo'and fromresolve_schema_inputwhen 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[], sofield_parts[0]raisesIndexError.Fix
Added a two-line guard in
llm/utils.pyafter buildingfield_parts: if the list is empty,continueto the next field. Nameless fields are silently skipped, which is the least surprising behavior — the same way a blank field is already skipped by theif field.strip()filter above.Test
Added
test_schema_dsl_empty_field_nameintests/test_utils.pycovering both':just a description'(all-nameless input) and'name, :no name before colon'(mixed input). All 83 existing tests still pass.Fixes #1466