Azure / Azure/azure-sdk-for-rust

Expose Cosmos driver fault injection through the native ABI

Open
#5,233 0 comments 1 reaction 0 assignees View on GitHub
Client Cosmos
Dominant language
Rust
Stars
884
Forks
365
Avg merge
2d 19h
Merged PRs (30d)
109

Description

## Problem

`azure_data_cosmos_driver` supports transport-layer fault injection through `FaultInjectionRule`, but `azure_data_cosmos_driver_native` does not expose those rules through the C ABI. The native runtime builder explicitly defers complex nested configuration such as `with_fault_injection_rules` until a flat ABI representation exists, and the native crate currently builds the driver without its `fault_injection` feature.

This prevents language bindings from driving real failures through the native completion queue. For example, the Go v2 binding can translate a 429/3200 completion, but cannot deterministically inject one to verify packed status/sub-status decoding, retry-after, request charge, activity/session metadata, message/body copy-out, and final error classification after the native completion batch is freed.

The only current alternatives are synthetic C structs—which validate binding translation but not driver publication—or external proxy/emulator behavior that cannot populate every completion field deterministically.

## Proposed ABI surface

Add a flat, versionable native representation for:

- fault-injection rule identity and lifetime;
- operation/resource/region/transport conditions;
- injected HTTP status and Cosmos sub-status;
- delay and connection/transport failures;
- retry-after and custom response headers/body;
- probability, hit limit, start delay, and expiration;
- attaching rules at driver construction and releasing their owned memory.

The wrapper should enable the driver crate's `fault_injection` feature and translate the flat C structures into the driver's existing `FaultInjectionRule` types.

## Validation

Add C/native tests that submit an operation through a completion queue with a deterministic injected 429/3200 and verify:

1. the completion is produced through the normal driver pipeline;
2. status/sub-status and typed headers are populated;
3. retry-after, message, and body survive completion publication;
4. rule conditions and hit limits are honored;
5. rule/provider memory is released after driver teardown.

## Consumer

Azure SDK for Go PR Azure/azure-sdk-for-go#27482 currently adds synthetic native-completion coverage. Once this ABI exists, that test can be upgraded to a true driver fault-injection test without changing the public Go surface.

Contributor guide

Open the contributing guide

Research direction

Start with the azure_data_cosmos_driver_native runtime builder and its deferred with_fault_injection_rules path, then read FaultInjectionRule in azure_data_cosmos_driver. Trace how the native crate enables driver features and how completion queues publish results. Done means a versionable flat C representation supports the listed conditions and lifetime rules, with deterministic 429/3200 native tests covering completion fields, limits, and teardown.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, rust
Domain
backend-api-design, testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.