Repository navigation
fix: _parse_path fails to navigate a lone top-level bracket index - #236
Merged
tstadel merged 3 commits intoAug 7, 2026
Merged
Conversation
_parse_path special-cased a single-part path by returning the raw part (parts[0]) instead of wrapping it in glom.Path when there was only one path component. This works fine when that lone part is a string attribute name (glom accepts bare strings as specs), but breaks when it's an int bracket index: glom does not accept a raw int as a spec, so glom(obj, 0) raises a TypeError wrapped in GlomError, which _get_object_at_path then reports as a misleading "Object 'X' does not have a value at path '[0]'" -- even though index 0 clearly exists. This affects every object-store tool that takes a path parameter (get_from_object_store, get_slice_from_object_store, grep_object_store, sed_object_store, yq_object_store): any time an LLM tries to index the first/Nth item of a top-level list result -- the most natural first navigation move -- it gets a false "not found" error. Fixed by always using Path(*parts), which glom.Path already handles correctly for a single part (whether string or int) and for zero parts (returns the object unchanged, fixing a related uncaught IndexError on an empty bracket pair like "[]" that the old parts[0] access could hit -- _parse_path's own call site only catches glom.GlomError, not exceptions raised while building the path spec itself).
Member
|
@mittalpk thank you for the fix! |
tstadel
approved these changes
Aug 7, 2026
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 does this PR do?
Fixes
RichExplorer._parse_path()insrc/deepset_mcp/tokonomics/explorer.py: when a navigation path has exactly one component, it returned the raw part (parts[0]) instead of wrapping it inglom.Path. That's fine when the lone part is a string attribute name (glom accepts bare strings as specs), but breaks when it's an int bracket index —glomdoes not accept a rawintas a spec, soglom(obj, 0)raises aTypeErrorwrapped inGlomError, which_get_object_at_pathreports asObject 'X' does not have a value at path '[0]'— even though index 0 clearly exists.This affects every object-store tool that takes a
pathparameter (get_from_object_store,get_slice_from_object_store,grep_object_store,sed_object_store,yq_object_store): whenever an LLM tries to index the first/Nth item of a top-level list result — a very natural first navigation move — it gets a false "not found" error instead of the value.Bonus fix, same root cause: an empty bracket pair (
path="[]") previously raised an uncaughtIndexError(notGlomError) directly out of_parse_path, since_get_object_at_path'stry/except GlomErroronly wraps theglom()call itself, not the_parse_path()call that builds the spec. Fixed by the same change.Fix
Always use
Path(*parts).glom.Pathalready handles a single part correctly (string or int) and zero parts (returns the object unchanged) — the special-casing was unnecessary and the source of both bugs.How was this tested?
mainwith a standalone script usingInMemoryBackend/ObjectStore/RichExplorer(no live deepset Cloud credentials needed):test/unit/tokonomics/test_explorer.py:test_parse_path_lone_bracket_index,test_explore_lone_bracket_index_on_list,test_parse_path_empty_brackets. Confirmed all 3 fail against unpatchedexplorer.py(git stash) with the exactIndexError/ValueErrordescribed above, and pass after the fix.test_parse_path_simple, which previously asserted_parse_path("attr") == "attr"(a bare string) — that assertion encoded the old, inconsistent contract. Updated it to assert the now-uniformPathreturn type and verify it still navigates correctly viaglom.uv run --dev pytest -m "not integration"— 803 passed, 4 skipped (pre-existing, unrelated), no regressions.make lint/make format-check— clean.make types(mypy) — clean, 146 source files.Notes for the reviewer
Small, behavior-preserving fix — no change for existing multi-part paths (already used
Path(*parts)); only the previously-broken single-part case changes, from a crash/false-negative to correct navigation.