fix(pin): guard null content block in isPinReply - #263
Open
dex0shubham wants to merge 1 commit into
Open
Conversation
isPinReply took blocks[0] after only a `blocks.length !== 1` check and read `.type` off it. A null content block (e.g. an assistant turn `content: [null]` following a `@pxpipe pin ...` command) passes the length check, and `blocks[0]!.type` throws TypeError. The throw is caught upstream, so the effect is silent: pinning is disabled for that request - the raw `@pxpipe pin` command lines are forwarded to the model and the user's pinned rules are not re-emitted. Every sibling that walks content blocks here guards this first (isCommandOnlyTurn, pinLines, systemPinLines, stripFromMessage). Add the same `!!blk && typeof blk === 'object'` guard so a malformed turn is simply not treated as a pin reply.
dex0shubham
force-pushed
the
fix/pin-null-block
branch
from
September 2, 2026 07:14
8a527bc to
c5ef35e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
isPinReply(src/core/pin.ts) took the sole content block after a length check and read.typewithout guarding it:A
nullcontent block (e.g.{"role":"assistant","content":[null]}following a@pxpipe pin …command turn — the only path that evaluatesisPinReply) passes thelength !== 1check, andblocks[0]!.typethrowsTypeError: Cannot read properties of null (reading 'type').The throw is caught at the pin call site, so it doesn't 500 — instead the whole pin feature silently no-ops for that request: the raw
@pxpipe pin …command lines stay in the outbound body (forwarded to the model) and the user's pinned rules are not re-emitted at the tail.Every sibling that walks content blocks in this module guards this first (
isCommandOnlyTurn,pinLines,systemPinLines,stripFromMessageall doif (!blk || typeof blk !== 'object')).isPinReplywas the exception.Fix
Add the same
!!blk && typeof blk === 'object'guard, so a malformed turn is simply not treated as a pin reply.Added a regression test (
stripPinCommandswith a null assistant block after a pin command) — it throws on the old code and passes with the fix.Full suite green (1207/1207);
typecheckclean.