Skip to content

feat: support partial writes#773

Open
alespour wants to merge 17 commits intomainfrom
feat/partial-writes
Open

feat: support partial writes#773
alespour wants to merge 17 commits intomainfrom
feat/partial-writes

Conversation

@alespour
Copy link
Copy Markdown
Contributor

@alespour alespour commented Apr 29, 2026

Proposed Changes

Adds partial-write support with structured error details in PartialWriteError, including per-line lineNumber, errorMessage, and originalLine so callers can decide whether to drop/retry/fix specific lines in a batch.

This also aligns write routing with the rollout contract:

  • Default write endpoint is now /api/v3/write_lp
  • acceptPartial defaults to true (server default behavior)
  • accept_partial=false is sent only when partial writes are explicitly disabled
  • New compatibility option useV2Api routes writes to /api/v2/write for Clustered/v2-compatible backends

Configuration surfaces now include:

  • Write option: acceptPartial, useV2Api
  • Client config / connection string keys: writeAcceptPartial, writeUseV2Api
  • Environment variables: INFLUX_WRITE_ACCEPT_PARTIAL, INFLUX_WRITE_USE_V2_API

Validation:

  • useV2Api=true with noSync=true is rejected before request dispatch.

See Partial writes in InfluxDB documentation.

Example:

const client = new InfluxDBClient({
  host: 'http://localhost:8181',
  token: 'YOUR_TOKEN',
  database: 'my_db',
})

try {
  await client.write(lp) // acceptPartial=true by default
} catch (err) {
  if (err instanceof PartialWriteError) {
    for (const lineErr of err.lineErrors) {
      console.log(
        `line ${lineErr.lineNumber} failed: ${lineErr.errorMessage} (${lineErr.originalLine})`
      )
    }
  } else {
    console.log(err)
  }
}

Optional v2 compatibility mode:

const client = new InfluxDBClient({
  ...
  writeOptions: {
    useV2Api: true,
  },
})

await client.write(lp)

Checklist

  • CHANGELOG.md updated
  • Rebased/mergeable
  • A test has been added if appropriate
  • Tests pass
  • Commit messages are conventional

@alespour alespour marked this pull request as ready for review April 29, 2026 09:08
@alespour alespour requested a review from Copilot April 29, 2026 09:09
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds client-side support for InfluxDB v3 partial writes by introducing a structured PartialWriteError and aligning write routing defaults with the v3 /api/v3/write_lp contract, while preserving v2 compatibility via an explicit option.

Changes:

  • Introduces PartialWriteError (with per-line error details) and updates HttpError message formatting for v3 write errors.
  • Switches default write routing to /api/v3/write_lp, adds acceptPartial/useV2Api options, and wires them through connection string + env parsing.
  • Updates unit/integration tests and documentation to cover partial-write behavior and v2 compatibility mode.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/client/src/errors.ts Adds PartialWriteError + parsing utilities; adjusts v3 write error message formatting.
packages/client/src/impl/WriteApiImpl.ts Routes writes to v3 by default; adds accept_partial=false + useV2Api routing + validation; converts HttpError → PartialWriteError when applicable.
packages/client/src/options.ts Adds acceptPartial/useV2Api to WriteOptions, defaults, and parses new connection/env keys.
packages/client/src/InfluxDBClient.ts Documents new connection string and env configuration keys.
packages/client/test/unit/errors.test.ts Adds coverage for new v3 error formatting and PartialWriteError.fromHttpError.
packages/client/test/unit/Write.test.ts Updates expected write endpoints; adds tests for acceptPartial, useV2Api, validation, and PartialWriteError behavior.
packages/client/test/unit/Influxdb.test.ts Adds tests for connection string and env parsing of new write options; updates expected default write path in mocks.
packages/client/test/integration/e2e.test.ts Adds E2E assertions for partial-write structured errors and v2 compatibility behavior.
packages/client/test/unit/impl/node/NodeHttpTransport.test.ts Increases wait time / improves diagnostics for a cancellation-related timing assertion.
packages/client/test/unit/impl/browser/FetchTransport.test.ts Same timing stabilization for fetch transport test.
README.md Documents partial write defaults, PartialWriteError, and v2 compatibility option.
CHANGELOG.md Notes breaking change: v3 write defaults + partial write support.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/client/src/errors.ts
Comment thread packages/client/src/impl/WriteApiImpl.ts Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/client/src/errors.ts Outdated
Comment thread packages/client/src/impl/WriteApiImpl.ts Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/client/src/impl/WriteApiImpl.ts Outdated
Comment thread packages/client/src/impl/WriteApiImpl.ts
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/client/src/impl/WriteApiImpl.ts
Comment thread packages/client/src/impl/WriteApiImpl.ts Outdated
Comment thread README.md Outdated
Copy link
Copy Markdown
Contributor

@karel-rehor karel-rehor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partial review encountered a minor problem with comments that needs to be addressed.

Comment thread packages/client/src/options.ts Outdated
Copy link
Copy Markdown
Contributor

@karel-rehor karel-rehor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried the steps in PR description and in new README.md section with a local client and setup with Influxdb3 Core (with node v20.19.6 and latest v25.9). Everything works as documented.

Tests also run locally without issue.

Looks good to me. 🚴 🏁

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.

3 participants