Skip to content

fix: correct indentation bug in MsgBatchSigner._prepare_messages#58

Merged
emilyzheng merged 1 commit intorelease-engineering:mainfrom
arewm:fix-batch-signer-indentation
Jan 22, 2026
Merged

fix: correct indentation bug in MsgBatchSigner._prepare_messages#58
emilyzheng merged 1 commit intorelease-engineering:mainfrom
arewm:fix-batch-signer-indentation

Conversation

@arewm
Copy link
Copy Markdown
Contributor

@arewm arewm commented Jan 22, 2026

Summary

  • Fix incorrect indentation in MsgBatchSigner._prepare_messages that caused O(N²) message duplication when signing requests span multiple repositories
  • Add test case to verify correct batching behavior with multiple repos

Problem

The run_in_parallel and messages.extend calls were incorrectly indented inside the repo loop. Since batch_data accumulates across all repos but was processed inside the loop, each repo iteration would re-process all accumulated batches.

Example with 3 repos (chunk_size=2, 3 digests per repo):

Repos Buggy Messages Fixed Messages Duplication
1 2 2 1.0x
2 6 4 1.5x
3 12 6 2.0x
10 110 20 5.5x
100 10,100 200 50.5x

This was causing signing tasks to timeout in production when processing large numbers of images across multiple repositories.

Fix

Move the two affected lines outside the repo loop (dedent by 4 spaces):

             batch_data.append(fdata)

-            ret = run_in_parallel(self._create_msg_batch_message, batch_data)
-            messages.extend(list(ret.values()))
+        ret = run_in_parallel(self._create_msg_batch_message, batch_data)
+        messages.extend(list(ret.values()))
         return messages

Test plan

  • Added test_prepare_messages_multi_repo_no_duplication test that:
    • Verifies run_in_parallel is called exactly once (not once per repo)
    • Verifies correct number of batches are created
    • Verifies each repo has the expected batch count

🤖 Generated with Claude Code

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jan 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (df19a66) to head (d0a90d0).

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #58   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           24        24           
  Lines         1272      1272           
=========================================
  Hits          1272      1272           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@arewm arewm force-pushed the fix-batch-signer-indentation branch from f837844 to 33b7e46 Compare January 22, 2026 03:48
The `run_in_parallel` and `messages.extend` calls were incorrectly
indented inside the repo loop, causing batch_data to be processed
multiple times - once per repo iteration. Since batch_data accumulates
across all repos, this led to O(N²) message duplication.

With the buggy code, signing requests spanning multiple repos would
send duplicate batches to the signing service, causing timeouts and
unnecessary load.

For example, with 3 repos:
- Buggy code: 2 + 4 + 6 = 12 messages (with duplicates)
- Fixed code: 2 + 2 + 2 = 6 messages (no duplicates)

The fix moves these two lines outside the repo loop so batch_data is
processed exactly once after all repos have been iterated.

Assisted-by: Claude Code (Opus 4.5)
Signed-off-by: arewm <arewm@users.noreply.github.com>
@arewm arewm force-pushed the fix-batch-signer-indentation branch from 33b7e46 to d0a90d0 Compare January 22, 2026 03:51
@emilyzheng emilyzheng merged commit 8d14408 into release-engineering:main Jan 22, 2026
7 checks passed
@arewm arewm deleted the fix-batch-signer-indentation branch January 22, 2026 13:03
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.

3 participants