Skip to content

fix(load): consume blank before-load hook replacements - #512

Merged
ss-o merged 1 commit into
nextfrom
bug-511
Sep 12, 2026
Merged

fix(load): consume blank before-load hook replacements#512
ss-o merged 1 commit into
nextfrom
bug-511

Conversation

@ss-o

@ss-o ss-o commented Sep 12, 2026

Copy link
Copy Markdown
Member

Problem

(z) splits a blank string into one empty word. A before-load hook that
consumed its final request successfully and returned an empty
ZI[annex-before-load:new-@] therefore reached the loader as a blank object
ID, and the dispatcher reported No plugin or snippet ID given (zi.zsh:3086)
with status 2 instead of succeeding with nothing loaded.

Verified directly:

raw=[]    count=1 elems=''
raw=[  ]  count=1 elems=''
raw=[x  ] count=1 elems='x'

Change

Drop the word when the replacement holds no non-whitespace character. The test
is the whitespace-stripped string, not -n, because whitespace-only splits to
the same single blank word and would otherwise slip through.

The same split affects ZI[annex-before-load:new-global-ices] at the sibling
call site: a blank ice-list became a one-element array, failed the even-count
check, and cost a spurious Bad new-ices returned warning plus 7 added to the
return status. Same guard applied there.

Quoted non-empty replacements, following requests, and odd hook failure
statuses are unchanged.

Verification

  • Full tests/ suite: 26 files, all pass. zsh -n clean on both changed files.
  • scripts/public-contract-impact.zsh against next: no public-contract
    changes detected.
  • Three negative runs, each confirming a distinct guard is actually covered:
    • guard removed at new-@ fails the plain-empty case
    • guard removed at new-global-ices fails the blank-ice-list case
    • guard narrowed back to -n fails the whitespace case, which is what makes
      the widening load-bearing rather than cosmetic

Acceptance

  • Empty successful replacement returns zero and loads no object.
  • Empty failed replacement preserves the hook error (status 3).
  • A following request and a quoted non-empty replacement retain their
    arguments and execute normally.
  • Native Zsh syntax and the focused dispatcher/load tests pass.
  • Recheck meta-plugins first expansion, retry, and repeated-group behavior
    against the corrected dispatcher.

Open item for review

The last box is deliberately unchecked. It is a cross-repository recheck that
belongs to z-shell/z-a-meta-plugins#60, which is blocked by this issue and runs
after it. A synthetic zi-plus-annex harness did not reach the all-members-loaded
state: with ._zi markers present and members listed in zsh_loaded_plugins,
the handler still queued every member, so $loaded_plugins[(I)$p] is not
matching as expected at handler line 200. That is a hint for whoever builds the
real integration fixture, not a defect claim in this change.

This pull request therefore references the issue rather than closing it. Leave
#511 open until that recheck lands alongside z-shell/z-a-meta-plugins#60.

Refs #511

`(z)` splits a blank string into one empty word, so a before-load hook
that consumed its final request and returned an empty
`ZI[annex-before-load:new-@]` reached the loader as a blank object ID and
failed with "No plugin or snippet ID given".

Drop the word when the replacement holds no non-whitespace character.
Apply the same guard to `new-global-ices`, where the stray word made an
empty ice-list look odd and malformed, costing a spurious warning and 7
added to the return status.

Quoted non-empty replacements, following requests, and odd hook failure
statuses are unchanged.

Refs #511
@ss-o
ss-o requested a review from a team as a code owner September 12, 2026 06:34
Copilot AI balanced review requested due to automatic review settings September 12, 2026 06:34

Copilot AI 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.

🟢 Approval recommended

The reviewed changes address the reported issue and include regression coverage.

Pull request overview

Fixes before-load hook handling so blank replacements no longer become invalid object IDs or malformed ice lists.

Changes:

  • Handles blank and whitespace-only replacements safely.
  • Preserves failure, follow-up, and quoted replacement behavior.
  • Adds focused regression coverage.
File summaries
File Summary
zi.zsh Guards blank hook replacements and ice lists.
tests/load-object-status.zsh Adds focused dispatcher regression tests.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite (auto)

Note

Copilot is running an experiment and ran this review at Lite.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@ss-o
ss-o merged commit b7e4584 into next Sep 12, 2026
100 checks passed
@ss-o
ss-o deleted the bug-511 branch September 12, 2026 09:14
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.

2 participants