feat: support partial writes#269
Open
alespour wants to merge 22 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds partial-write support to the C# client (including structured per-line error details) and finalizes write routing behavior between InfluxDB’s V2 and V3 write endpoints for product compatibility.
Changes:
- Introduces
InfluxDBPartialWriteExceptionand JSON error parsing to surface v3 partial-write line errors. - Adds write routing/behavior controls via
WriteOptions(UseV2Api,AcceptPartial,NoSync) plus connection string/env var configuration. - Updates tests and docs to reflect default V2 routing and explicit V3 option behavior.
Reviewed changes
Copilot reviewed 12 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents partial writes and explains default V2 routing + configuration surfaces. |
| Client/Internal/RestClient.cs | Parses JSON error bodies; throws InfluxDBPartialWriteException with structured line errors on v3 partial-write responses. |
| Client/InfluxDBPartialWriteException.cs | Adds new exception type carrying per-line partial-write error details. |
| Client/InfluxDBClient.cs | Routes writes to /api/v2/write by default and applies v3-only query params (no_sync, accept_partial) when using v3. |
| Client/Config/WriteOptions.cs | Adds AcceptPartial/UseV2Api options and validates NoSync usage. |
| Client/Config/ClientConfig.cs | Adds connection string/env parsing for writeAcceptPartial and writeUseV2Api. |
| Client/Client.csproj | Adds System.Text.Json dependency for JSON parsing. |
| Client.Test/Internal/RestClientTest.cs | Adds/updates tests for partial-write error parsing and typed/untyped fallback behavior. |
| Client.Test/InfluxDBClientWriteTest.cs | Updates tests for default V2 routing, explicit V3 routing, and option validation/guidance messages. |
| Client.Test/InfluxDBClientHttpsTest.cs | Formatting-only change. |
| Client.Test/InfluxDBApiExceptionTest.cs | Formatting-only change. |
| Client.Test/Config/ClientConfigTest.cs | Extends tests to cover new connection string/env write options. |
| Client.Test.Integration/WriteTest.cs | Refactors exception check using pattern matching. |
| CHANGELOG.md | Adds unreleased feature entry for partial writes + default V2 routing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 15 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
Client/InfluxDBClient.cs:848
- This guidance error message starts with a lowercase "server" while other user-facing exceptions in the client are capitalized (e.g., "Cannot write..."). Consider capitalizing this message for consistency.
throw new InfluxDBApiException(
$"server doesn't support the V3 API endpoint (/api/v3/write_lp) " +
$"(set UseV2Api=true; write options: {{UseV2Api:false,NoSync:{writeOptions.NoSync.ToString().ToLowerInvariant()},AcceptPartial:{writeOptions.AcceptPartial.ToString().ToLowerInvariant()}}})",
ex.HttpResponseMessage!);
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
Proposed Changes
This PR adds partial-write support in the C# client and finalizes write API selection behavior for product compatibility.
Feature highlights:
InfluxDBPartialWriteExceptionwith per-line details:LineNumberErrorMessageOriginalLineAcceptPartialdefaults totrue(server default behavior)accept_partial=falseis sent only when partial writes are explicitly disabledUseV2Apiroutes writes between:/api/v2/write/api/v3/write_lpDefault behavior and option semantics:
UseV2Api=true).NoSyncrequiresUseV2Api=falseand is rejected otherwise.AcceptPartialapplies only to V3 endpoint writes and is ignored on V2 endpoint writes.Configuration surfaces:
AcceptPartial,UseV2Api,NoSyncwriteAcceptPartial,writeUseV2Api,writeNoSyncINFLUX_WRITE_ACCEPT_PARTIAL,INFLUX_WRITE_USE_V2_API,INFLUX_WRITE_NO_SYNCSee Partial writes for reference.
Example (partial-write handling):
Example (enable V3 write options):
Checklist