Skip to content

fix: Handle string entities/edges in _validate_and_process#73

Open
calvinguo721 wants to merge 1 commit into666ghj:mainfrom
calvinguo721:fix-ontology-validation
Open

fix: Handle string entities/edges in _validate_and_process#73
calvinguo721 wants to merge 1 commit into666ghj:mainfrom
calvinguo721:fix-ontology-validation

Conversation

@calvinguo721
Copy link

Problem

When LLM returns malformed JSON where entity_types or edge_types contain strings instead of dictionaries, the _validate_and_process method crashes with:

TypeError: 'str' object does not support item assignment

Solution

Added type checking in _validate_and_process:

  • If entity/edge is a string, wrap it into proper dict format
  • Skip invalid (non-dict) entries to prevent crashes
  • Collect valid entries into new lists

Testing

Tested with DeepSeek model via OpenRouter. Successfully generates ontology without crashes.

Add type checking to prevent crashes when LLM returns malformed JSON
where entity_types or edge_types contain strings instead of dicts.

- Wrap string entities into {name, description} format
- Skip invalid (non-dict) entries
- Collect valid entries into new lists

Fixes TypeError: 'str' object does not support item assignment
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. LLM API Any questions regarding the LLM API labels Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LLM API Any questions regarding the LLM API size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant