-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Owner Resource Not Found (Gateway V2 Connection Mode and Direct Connection Mode): Remaps sub-status to 1003 for requests to child resources against non-existent container. #47604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Owner Resource Not Found (Gateway V2 Connection Mode and Direct Connection Mode): Remaps sub-status to 1003 for requests to child resources against non-existent container. #47604
Conversation
|
/azp run java - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds sub-status code 1003 (Owner Resource Not Found) for requests to child resources (e.g., documents) when the owning container doesn't exist. The changes ensure proper error reporting across Direct Mode, Gateway V2 Mode, and Gateway Mode connection types.
Key Changes
- Added error mapping logic to set sub-status code 1003 when container resolution fails during child resource operations
- Introduced new
setSubStatusCodemethod in CosmosException API via ImplementationBridgeHelpers - Added comprehensive test coverage for container not found scenarios across different connection modes
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| QueryPlanRetriever.java | Added error mapping to set sub-status 1003 for 404 errors during query plan retrieval |
| RxCollectionCache.java | Added error mapping handlers in collection resolution paths to set sub-status 1003 for child resource operations |
| StaleResourceRetryPolicy.java | Added enclosingOperationTargetResourceType parameter and error mapping logic for retry scenarios |
| RxDocumentClientImpl.java | Updated retry policy instantiation with ResourceType.Document parameter for point operations |
| ImplementationBridgeHelpers.java | Added setSubStatusCode method to CosmosExceptionAccessor interface |
| CosmosException.java | Implemented setSubStatusCode accessor method |
| CosmosNotFoundTests.java | New comprehensive test class covering non-existent and deleted container scenarios |
| FaultInjectionTestBase.java | Enhanced helper methods to support bulk operations and feed range testing |
| StaleResourceExceptionRetryPolicyTest.java | Updated test constructor calls with new null parameter |
sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosNotFoundTests.java
Outdated
Show resolved
Hide resolved
sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RxDocumentClientImpl.java
Outdated
Show resolved
Hide resolved
...mos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/caches/RxCollectionCache.java
Outdated
Show resolved
Hide resolved
...mos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/caches/RxCollectionCache.java
Outdated
Show resolved
Hide resolved
sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosNotFoundTests.java
Show resolved
Hide resolved
sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosNotFoundTests.java
Show resolved
Hide resolved
sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosNotFoundTests.java
Outdated
Show resolved
Hide resolved
...mos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/StaleResourceRetryPolicy.java
Outdated
Show resolved
Hide resolved
...mos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/caches/RxCollectionCache.java
Outdated
Show resolved
Hide resolved
...mos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/caches/RxCollectionCache.java
Outdated
Show resolved
Hide resolved
…into AzCosmos_RemapSubStatusForDocRequestsAgainstNonExistentContainer
|
/azp run java - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
...mos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/StaleResourceRetryPolicy.java
Outdated
Show resolved
Hide resolved
...mos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/StaleResourceRetryPolicy.java
Outdated
Show resolved
Hide resolved
...mos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/StaleResourceRetryPolicy.java
Outdated
Show resolved
Hide resolved
...mos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/caches/RxCollectionCache.java
Outdated
Show resolved
Hide resolved
|
/azp run java - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
...mos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/caches/RxCollectionCache.java
Outdated
Show resolved
Hide resolved
sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RxDocumentClientImpl.java
Outdated
Show resolved
Hide resolved
| AtomicReference<String> oldCollectionRid = new AtomicReference<>(); | ||
| return this.clientCollectionCache | ||
| .resolveByNameAsync(this.getMetadataDiagnosticsContext(), collectionLink, requestOptionProperties) | ||
| .resolveByNameAsync(this.getMetadataDiagnosticsContext(), collectionLink, requestOptionProperties, null, this.request, this.enclosingOperationTargetResourceType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when would this.request.getOperationType != this.enclosingOperationTargetResourceType?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Above is not expected to be unequal. This is primarily for defense in depth. The request entity is set once StaleResourceRetryPolicy is already instantiated whereas enclosingOperationTargetResourceType is set through the constructor (more guarantees to be initialized).
|
|
||
| CosmosException cosmosException = Utils.as(throwable, CosmosException.class); | ||
|
|
||
| if (HttpConstants.StatusCodes.NOTFOUND == (cosmosException.getStatusCode())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sam question -> would this still be needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'd think - the QueryPlan call goes through RxGatewayStoreModel and gets a 404/0 back when the corresponding collection doesn't exist. This is slightly different for other Document calls whose call path peek into RxCollectionCache first. So remapping is done in QueryPlanRetriever (wanted to keep the transport layer devoid of business logic).
xinlian12
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks
|
/azp run java - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run java - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run java - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Description
The objective of this PR is to add
Owner Resource Not Found(1003) as sub-status code mapping when the owning resource is not found specifically theDocumentCollectionresource. The main motivation is disambiguation - is it the child resource not present (such as a document) or its encapsulating resource such as a container. This can help an application developer debug better.Scenarios tested and fixed
For Direct Mode and Gateway V2 Mode, ensure both container never existed and stale container cache scenarios are appropriately handled.
For Gateway Mode, ensure container never existed scenarios are appropriately handled.
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines