Repository navigation
cli: resolve numeric kg find-path IDs on integer-keyed graphs - #2186
Conversation
Click passes --from/--to as strings, but Neo4j-backed graphs key nodes by integer ID, so _resolve_entity could never match a numeric ID (semantica-agi#2179). Retry a numeric token as an int, keep name resolution unchanged, and stringify IDs in the ambiguous-name error. Adds regression tests for numeric IDs, string IDs and the ambiguous path.
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
PR Summary by QodoResolve numeric find-path IDs on integer-keyed graphs
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1.
|
…tching isdigit() accepts characters int() rejects (e.g. superscripts), and int() caps digit-string length, so the numeric retry in _resolve_entity could raise ValueError before the name fallback or the unknown-entity error. Guard the conversion and add regression tests. Addresses review feedback on PR semantica-agi#2186.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
Confirmed and fixed in ed8fbb4 (plus test formatting in d57498b). The numeric retry now guards the int() conversion, so tokens like ² or a 5000-digit string fall through to name matching and the documented unknown-entity error instead of raising ValueError. Three regression tests added: superscript digit token -> unknown-entity ClickException, overlong digit token -> unknown-entity ClickException, superscript-containing name still resolves by name. Verified fail-before (2 new tests fail on the previous head) and pass-after (8/8). |
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
pkupt
left a comment
There was a problem hiding this comment.
@charan-rathore thanks for this. I pulled the branch and ran it: tests/cli/test_cli_find_path.py gives 8 passed and tests/cli gives 36 passed. Swapping cli.py back to main turns exactly two tests red, the integer-node one and the ambiguous-name one, so both halves of the change are covered. LGTM.
One small thing, not blocking: isdigit() also accepts digits like ٣, and int() happily turns that into 3, so a name that looks numeric could resolve to a node instead of falling through to name matching. token.isascii() before isdigit() would close that if you think it is worth it.
Description
kg find-path --from 42 --to 7fails on graph stores that key nodes by integer ID (Neo4j), because Click passes every option value as a string and_resolve_entityonly ever compared the raw string token against node IDs. The command now retries a purely numeric token as an integer before falling back to name matching, so integer-keyed nodes resolve correctly.Type of Change
Related Issues
Fixes #2179
Changes Made
_resolve_entityinsemantica/cli.py: when the raw string token is not a node ID andtoken.isdigit(), retry membership asint(token)and return the integer ID on a hit.TypeError._resolve_entityguards theint()conversion so digit tokens it rejects (superscript digits, overlong digit strings) fall through to name matching and the documented unknown-entity error instead of raisingValueError.tests/cli/test_cli_find_path.py(8 tests): numeric token resolves an integer node ID, string token still resolves a string node ID, name fallback unchanged, ambiguous-name error lists integer IDs, unknown token raises a clear error, superscript digit token falls through to the unknown-entity error, overlong digit token falls through to the unknown-entity error, superscript-containing name still resolves by name.Testing
python -m build)Test Commands
pytest tests/cli/test_cli_find_path.py -q # 8 passedFail-before verified: on pristine
main(only the test file added), exactly the 2 regression tests fail; on this branch all 8 pass. The 3 Unicode/long-digit tests were likewise verified failing before theint()guard (2 fail, the name-resolution one already passed).Documentation
Breaking Changes
Breaking Changes: No
Checklist
Additional Notes
Baseline gaps on current
main, not introduced or altered by this change:semantica/cli.pyis notblack-clean on pristinemain(166 reformat hunks). This diff adds none of its own: the hunk count is identical before and after the branch, and the new test file isblack-clean.tests/kg/test_community_hierarchy.py::TestCommunityHierarchyEdgeCases::test_builder_fallback_flag_resets_on_subsequent_buildsfails on pristinemainand is not listed in.github/full-suite-known-failures.txt. It is unrelated to this change (no shared code path withsemantica/cli.py).