Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical and moderate findings affect native error handling and test reliability.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds specific-replica document reads to the Couchbase PHP API, including native bindings, strategies, options, exceptions, and integration tests.
Changes:
- Adds the
getReplica()API and replica-related types. - Wires native request handling and exception mapping.
- Adds integration coverage and Protostellar unsupported handling.
File summaries
| File | Reviewed change / final review notes |
|---|---|
tests/KeyValueGetReplicaTest.php |
Adds replica-read tests. Moderate: wait for asynchronous replica propagation; skip Protostellar runs; ensure the invalid index remains out of bounds when three replicas exist. |
src/wrapper/connection_handle.hxx |
Declares the native replica-read operation. |
src/wrapper/connection_handle.cxx |
Implements native replica reads. Critical: preserve and return unmapped response errors instead of falling through to result creation. |
src/wrapper/common.cxx |
Registers and maps replica exceptions. |
src/php_couchbase.cxx |
Exposes the native PHP function. |
Couchbase/ReplicaIndex.php |
Defines replica index constants. |
Couchbase/Protostellar/Collection.php |
Marks replica reads unsupported. Moderate: tests need a Protostellar guard; nit: use a scheme-neutral unsupported-operation message. |
Couchbase/GetReplicaStrategy.php |
Defines replica selection behavior. Nit: add coverage for wrap(true) fallback and exhausted-search behavior. |
Couchbase/GetReplicaOptions.php |
Defines replica-read options. |
Couchbase/Exception/ReplicaIndexOutOfBoundsException.php |
Adds the invalid-index exception. |
Couchbase/Exception/ReplicaIndexCurrentlyUnavailableException.php |
Adds the unavailable-replica exception. |
Couchbase/Exception/DocumentNotFoundOnReplicaException.php |
Adds the missing-document exception. |
Couchbase/CollectionInterface.php |
Adds the public method contract. |
Couchbase/Collection.php |
Implements the public getReplica() API. |
Review details
Suppressed comments (3)
Couchbase/Protostellar/Collection.php:312
- This backend deliberately throws
UnsupportedOperationExceptionforgetReplica, butskipIfReplicasAreNotConfigured()returns without skipping on Protostellar. Consequently the three newgetReplicatests invoke this method and fail in Protostellar runs instead of being skipped. Add a Protostellar guard to those tests, or implement the operation for this backend.
public function getReplica(string $key, GetReplicaStrategy $strategy, ?GetReplicaOptions $options = null): GetReplicaResult
{
throw new UnsupportedOperationException("getReplica is not supported with the couchbase2 scheme yet");
tests/KeyValueGetReplicaTest.php:90
skipIfReplicasAreNotConfigured()returns immediately for Protostellar, whileProtostellar\Collection::getReplica()always throwsUnsupportedOperationException. Consequently this test fails in Protostellar test runs instead of asserting the intended exception; add the Protostellar skip before the replica configuration check.
$this->skipIfReplicasAreNotConfigured();
tests/KeyValueGetReplicaTest.php:100
- Unlike the other new tests, this test has no Protostellar skip, and
Protostellar\Collection::getReplica()always throwsUnsupportedOperationException. It therefore fails in Protostellar test runs before reaching the expected out-of-bounds assertion; skip Protostellar connections for this unsupported operation.
$id = $this->uniqueId();
$collection = $this->defaultCollection();
- Files reviewed: 15/15 changed files
- Comments generated: 6
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Wrapping behavior is not actually exercised, and the new observability path lacks coverage.
Review effort: Balanced
Findings: 2
Open (2)
Resolved since last review (6)
key_value_executereturns a non-emptyerrwheneverresp.ctx.ec()is set, but this branch only… The replica check only verifies that the bucket has at least one replica, so it also permits a… The upsert is acknowledged by the active node only, while replica propagation is asynchronous.…skipIfReplicasAreNotConfigured()returns immediately for Protostellar, while… This implementation is used for bothprotostellar://andcouchbase2://connections, so the… The newwrap(true)behavior is not exercised by any of the added integration tests; all calls use…
avsej
approved these changes
Sep 30, 2026
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.



No description provided.