Skip to content

fix(buffers): assertion failed when buflist is nil - #2754

Draft
phanen wants to merge 1 commit into
mainfrom
fix/buffers
Draft

fix(buffers): assertion failed when buflist is nil#2754
phanen wants to merge 1 commit into
mainfrom
fix/buffers

Conversation

@phanen

@phanen phanen commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Problem: contents callback calls utils.CTX() without includeBuflist,
so if the context was recreated between core.lua:346 (which passes
includeBuflist=true) and the async contents invocation, buflist is
nil and the assertion crashes. The same file already handles this at
line 282 with utils.CTX().buflist or {}.

Solution: pass { includeBuflist = true } explicitly, ensuring the ctx
always has buflist populated when accessed inside the callback.

Closes #2736

Summary by CodeRabbit

Release Notes

No user-visible changes in this update. Internal implementation adjustments have been made to improve code reliability.

Problem: `contents` callback calls `utils.CTX()` without `includeBuflist`,
so if the context was recreated between `core.lua:346` (which passes
`includeBuflist=true`) and the async `contents` invocation, `buflist` is
nil and the assertion crashes. The same file already handles this at
`line 282` with `utils.CTX().buflist or {}`.

Solution: pass `{ includeBuflist = true }` explicitly, ensuring the ctx
always has `buflist` populated when accessed inside the callback.

Closes #2736
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fa190fb3-19e5-4419-a6f6-92211ba76bac

📥 Commits

Reviewing files that changed from the base of the PR and between 267f5db and fb07c7f.

📒 Files selected for processing (1)
  • lua/fzf-lua/providers/buffers.lua

📝 Walkthrough

Walkthrough

In M.buffers, the contents closure changes how buflist is retrieved: instead of assert(utils.CTX().buflist), it now calls utils.CTX({ includeBuflist = true }).buflist, passing an option to include the buffer list in the context rather than asserting its presence.

Changes

Buflist context retrieval fix

Layer / File(s) Summary
buflist retrieval in M.buffers
lua/fzf-lua/providers/buffers.lua
buflist is now obtained via utils.CTX({ includeBuflist = true }).buflist instead of assert(utils.CTX().buflist), removing the hard assertion that caused intermittent failures when buflist was absent from the context.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

A bunny once stumbled on an assert so mean,
That crashed without warning mid-hop on the green.
Now CTX gets a nudge — "include the buflist, please!"
No more panics at dusk, no more failures to tease.
🐇✨ Smooth hops all around, with no error to seize!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing an assertion failure when buflist is nil in the buffers provider.
Linked Issues check ✅ Passed The code change directly addresses issue #2736 by preventing the nil assertion failure through explicitly passing includeBuflist=true parameter.
Out of Scope Changes check ✅ Passed The change is narrowly scoped to fixing the specific assertion failure in buffers.lua by modifying how buflist is retrieved, with no extraneous modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/buffers

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.

@ibhagwan

Copy link
Copy Markdown
Owner

So you found it :)

@phanen
phanen marked this pull request as draft June 19, 2026 16:10
@phanen

phanen commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator Author

no, it's still a llm slop, I don't understand the real reason. Give llm more time to persuude me...

@ibhagwan

ibhagwan commented Jul 5, 2026

Copy link
Copy Markdown
Owner

GLM 5.2 is also convinced this is the right fix though I couldn’t reproduce this with its repro steps even when adding uv.sleep to make the refresh slower:
image

@phanen

phanen commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator Author

Fun fact I never reproduce since then..

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.

fzf-lua/providers/buffers.lua:219: assertion failed!

2 participants