Skip to content

fix(acp): guard vim.NIL in tool-call message builder#263

Merged
carlos-algms merged 2 commits into
mainfrom
fix/acp-tool-call-vim-nil-userdata
Jun 11, 2026
Merged

fix(acp): guard vim.NIL in tool-call message builder#263
carlos-algms merged 2 commits into
mainfrom
fix/acp-tool-call-vim-nil-userdata

Conversation

@carlos-algms

@carlos-algms carlos-algms commented Jun 10, 2026

Copy link
Copy Markdown
Owner
  • providers send JSON null for tool-call fields
  • vim.NIL is truthy userdata, broke ipairs/index
  • crashed on session restore via __build_tool_call_message
  • guards content, locations, rawInput

- providers send JSON null for tool-call fields
- vim.NIL is truthy userdata, broke ipairs/index
- restore session no longer crashes
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5d17650b-f399-4e8b-a238-488f4513d885

📥 Commits

Reviewing files that changed from the base of the PR and between 326682f and fc0b9af.

📒 Files selected for processing (3)
  • .agents/skills/agentic-acp-protocol-flow/references/transport-framing.md
  • lua/agentic/acp/acp_transport.lua
  • lua/agentic/acp/acp_transport.test.lua

📝 Walkthrough

Walkthrough

This PR tightens ACPClient:__build_tool_call_message to only treat update.content, update.rawInput, and update.locations as iterables or fallback sources when they are explicitly tables. It also adds ACPTransport.decode_line — a wrapper around vim.json.decode using luanil so JSON null maps to Lua nil — replaces inline decoding in the stdout loop with this helper, and adds tests and docs verifying null→nil decoding and malformed JSON handling.

Sequence Diagram(s)

sequenceDiagram
  participant StdoutReader
  participant ACPTransport
  participant vim_json_decode
  participant Callbacks
  StdoutReader->>ACPTransport: send non-empty line
  ACPTransport->>vim_json_decode: decode(line, { luanil = { object = true, array = true } })
  vim_json_decode-->>ACPTransport: (ok, decoded)  Note right of ACPTransport: JSON null -> Lua nil
  ACPTransport->>Callbacks: callbacks.on_message(ok, decoded)
Loading

Possibly related PRs

Poem

🐰 I hop through lines of code with glee,
Nulls become nils for you and me,
Tables-only gates now stand up tall,
Errors flee and tests recall,
A rabbit cheers the safer call.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly addresses the main change: adding guards for vim.NIL in the tool-call message builder to fix crashes.
Description check ✅ Passed The description relates to the changeset by explaining the problem (vim.NIL causing crashes) and the solution (guarding content, locations, rawInput fields).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/acp-tool-call-vim-nil-userdata

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@carlos-algms carlos-algms marked this pull request as ready for review June 10, 2026 20:24
@carlos-algms carlos-algms merged commit 021d1e0 into main Jun 11, 2026
10 checks passed
@carlos-algms carlos-algms deleted the fix/acp-tool-call-vim-nil-userdata branch June 11, 2026 12:43
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.

1 participant