Skip to content

fix(bash): read the call after a keyword parsed as a command name (#5572) - #5576

Closed
yashsaxena wants to merge 1 commit into
Graphify-Labs:v8from
yashsaxena:bash-keyword-command
Closed

yashsaxena wants to merge 1 commit into
Graphify-Labs:v8from
yashsaxena:bash-keyword-command

Conversation

@yashsaxena

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #5572.
In a function, a line of assignments only (as in v=a w="$(echo b)") followed by elif ok "$1"; then can parse as one command whose name is the keyword elif, so walk_calls took elif as the callee and the call to ok was lost.
When the command's name is one of if then elif else do while until, the callee is now the first word after it, a ! aside.

Type of change

  • Bug fix

Verification & Invariants

Invariant: a keyword is never recorded as a callee; every other command name is read as before.
The change only runs when the name is one of the seven keywords, which bash never runs as a command.

  • Read the CONTRIBUTING.md guide.
  • Reproduced the issue (Bash extractor: a call after elif, then or do is lost when the line before holds only assignments (v=a w="$(f)") #5572, on graphifyy 0.9.122 from PyPI).
  • Made the smallest fix necessary.
  • Added a regression test: test_extract_bash_call_after_keyword_following_assignments_recorded checks the main -> ok call and that no keyword is a raw callee.
  • Kept the PR description synchronized with the final implementation.
  • Documented any limitations / unsupported cases explicitly: only walk_calls (calls inside function bodies) is changed; the top-level walk() reads commands through child_by_field_name("name") the same way and is left as it is.

How was this tested?

I could not run the suite on my machine, so this repo's own CI workflow ran on the branch in my fork:

CI workflow (workflow_dispatch) on yashsaxena/graphify@bash-keyword-command: all jobs pass
(skillgen-check, test 3.11/3.12/3.13/3.14, pi-guard, security-scan)
test (3.12): 12062 passed, 119 skipped, 2 xfailed   (serial pass: 285 passed, 3 skipped)

Graphify-specific checklist

  • I updated generated skill artifacts: not needed, no fragments changed.
  • Extraction stays deterministic (no ENV reads).
  • Reviewed for security: no new filesystem probe.
  • No API keys or local graph data.
  • AI authorship disclosed in the commit message (Co-Authored-By: Claude).

…aphify-Labs#5572)

A line of assignments only, then `elif ok x; then`, can parse as one command
named `elif`. The call is now the first word after the keyword.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown

Thanks for the pull request, @yashsaxena. A maintainer will review it soon.

Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions.

A couple of things that speed up review: make sure the test suite passes on Python 3.11 and 3.13, and that the change keeps extraction deterministic.

@graphify-labs graphify-labs Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graphify review View in Graphify

Nothing blocking · 3 possible issues to check · Merge confidence 5/5

3 possible issues to check · High impact

When a parsed command name is a control-flow keyword, the extractor searches the command’s children for a word to treat as the callee.

3 possible issues we couldn't confirm

They don't change the score.

What this review covered
  • Some findings could not be double-checked.
  • 2 of 2 changed files inspected. This is scope, not a correctness guarantee.
Code graph · 621 functions depend on this change
  • 1 function became more coupled. extract_bash() (53 callers).
  • 2 of 652 test files are affected by this change.
  • Gate, test list and every flagged function: in the Graphify check.

Reviewed c5ea966

@safishamsi

Copy link
Copy Markdown
Member

Shipped in v0.9.123, landed via authorship-preserving cherry-pick so your commits keep your name. Thanks @yashsaxena!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bash extractor: a call after elif, then or do is lost when the line before holds only assignments (v=a w="$(f)")

2 participants