Skip to content

fix: resolve variable shadowing of newSLR in IntegrateBatch - #3932

Open
Dev-next-gen wants to merge 1 commit into
google:masterfrom
Dev-next-gen:fix/sequencer-newslr-shadow
Open

Dev-next-gen wants to merge 1 commit into
google:masterfrom
Dev-next-gen:fix/sequencer-newslr-shadow

Conversation

@Dev-next-gen

Copy link
Copy Markdown

Summary

IntegrateBatch in log/sequencer.go declares newSLR in the outer function scope (line 282), but the closure passed to ReadWriteTransaction assigns it with := (line 403) instead of =. This creates a new local variable that shadows the outer one. After the transaction completes, the outer newSLR is still nil, so the condition on line 419 is never true and the klog.Infof("sequenced %v leaves, size %v", ...) message never fires.

Operators relying on log output to monitor sequencing activity see no "sequenced N leaves" messages, regardless of how many leaves are integrated.

Fix

Change := to = on line 403 so the assignment targets the outer variable.

Proof

Added TestIntegrateBatch_LogsSequencedLeaves which captures klog output after a successful batch integration. With the shadow bug, the buffer is empty (FAIL). With the fix, it contains the expected "sequenced" message (PASS).

Before fix:

--- FAIL: TestIntegrateBatch_LogsSequencedLeaves (0.00s)
    sequencer_test.go:750: expected log message containing 'sequenced' and tree ID '154035', got: ""

After fix:

--- PASS: TestIntegrateBatch_LogsSequencedLeaves (0.00s)

All existing tests in ./log/ continue to pass.

Found by a defect-hunting pipeline I build and run (Dev-next-gen), using Claude Code with Anthropic's Claude Opus 5.

The closure inside IntegrateBatch used := instead of = to assign
newSLR, creating a new local variable that shadows the outer one.
As a result, the outer newSLR stayed nil after the transaction,
and the "sequenced N leaves, size M" log message never fired.

Change := to = so the outer variable is correctly set, restoring
the sequencing activity log line that operators depend on.
@Dev-next-gen
Dev-next-gen requested a review from a team as a code owner September 18, 2026 17:23

This branch has not been deployed

No deployments
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