Skip to content

Fix replication pull URL encoding for special characters in checkpoint ID#405

Merged
pubkey merged 1 commit intomasterfrom
claude/fix-replication-endpoint-bug-4NQmY
Apr 15, 2026
Merged

Fix replication pull URL encoding for special characters in checkpoint ID#405
pubkey merged 1 commit intomasterfrom
claude/fix-replication-endpoint-bug-4NQmY

Conversation

@pubkey
Copy link
Copy Markdown
Owner

@pubkey pubkey commented Apr 14, 2026

This PR contains:

  • A BUGFIX
  • IMPROVED TESTS

Describe the problem you have without this PR

When replicating documents whose primary key contains URL-reserved characters (such as &, #, =), the replication pull request URL was not properly encoding the checkpoint id parameter. This caused the server to parse the URL incorrectly, truncating the checkpoint ID at the first special character. With batchSize: 1, this prevented the pull loop from advancing past documents with such primary keys, causing replication to hang.

Changes

Source Code

  • src/plugins/replication-server/index.ts: Added encodeURIComponent() call when constructing the pull request URL to properly encode the checkpoint id parameter that may contain URL-reserved characters.

Tests

  • test/unit/endpoint-replication.test.ts: Added comprehensive test case should replicate documents whose primary key contains url-unsafe characters that verifies replication works correctly with primary keys containing special characters like &. The test uses batchSize: 1 to ensure the encoded checkpoint ID is actually sent back to the server on subsequent pulls.

Documentation

  • CHANGELOG.md: Added entry documenting the bug fix.

Test Plan

The new test case should replicate documents whose primary key contains url-unsafe characters covers this fix by:

  1. Creating documents with primary keys containing URL-reserved characters (&)
  2. Setting up a replication endpoint and client
  3. Using batchSize: 1 to force the checkpoint ID to be sent back to the server
  4. Verifying that all documents are successfully replicated to the client

Existing tests continue to pass, confirming no regression in normal replication scenarios.

https://claude.ai/code/session_01KrbsDQ3tY2qPsJaaoGbWVa

When a document's primary key contained URL-reserved characters
(e.g. `&`, `#`, `=`), the `id` in the pull URL was parsed incorrectly
by the server: the checkpoint got truncated at the first reserved
char. With batchSize 1 this caused the pull loop to never advance
past such a document, since the server kept returning the same doc.

The client now passes `id` through `encodeURIComponent`.

https://claude.ai/code/session_01KrbsDQ3tY2qPsJaaoGbWVa
@pubkey pubkey merged commit 00e8974 into master Apr 15, 2026
2 checks passed
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