Skip to content

Add tests for write-path error handling and packaging bugs - #80

Merged
jstirnaman merged 4 commits into
mainfrom
claude/influxdb3-mcp-server-tests-f6irxy
Jul 28, 2026
Merged

Add tests for write-path error handling and packaging bugs#80
jstirnaman merged 4 commits into
mainfrom
claude/influxdb3-mcp-server-tests-f6irxy

Conversation

@jstirnaman

Copy link
Copy Markdown
Collaborator

Summary

Four version-independent bugs found while auditing for InfluxDB 3.11 compatibility, none previously covered by tests:

  • Write-path error body loss. handleWriteError (src/services/write.service.ts) discards InfluxDB's response body for 400/401/403/413/422, has no 503 arm, and renders parsed JSON bodies as [object Object]. handleQueryError already handles this correctly — the write path is the outlier. (write-error-core.test.ts, write-error-cloud.test.ts)
  • Write routing was untested. Which endpoint/transport each product type uses for writes, and that an unknown product type rejects rather than silently defaulting. (write-routing.test.ts)
  • zod is a misdeclared runtime dependency. Imported throughout src/tools/ but listed only in devDependencies, so a clean npm i --omit=dev breaks. (packaging.test.ts)
  • Protocol-boundary and ping gaps. write_line_protocol's advertised schema, error surfacing over the MCP protocol boundary, health_check's hasAnySuccess bug (reports HEALTHY even when both /ping and /health fail), and ping()'s version/build header passthrough. (protocol-write.test.ts, base-connection-ping.test.ts)

Also: test:integration now matches any *integration* test file instead of only integration.test.tsquery-error-integration.test.ts was never actually wired into the live-instance run.

Several describe.skip("[P<n>] ...") blocks are acceptance criteria for fixes not yet implemented, each paired with an active test asserting today's (wrong) behavior — implementing the fix flips both at once. See tests/README.md for the convention.

This PR does not include the code fixes for the bugs above — tests only, characterizing current behavior.

Split off a broader InfluxDB 3.11 compatibility pass: the version-gated parts (live-instance tests, the 3.11 tool-surface guardrail, open questions) moved to a separate influxdb-3.11-compat-patch branch instead of landing here.

Test plan

  • npm run build && npx vitest run — 88 passed, 30 skipped (skips are deliberate: unimplemented-fix acceptance criteria, and live-instance tests without INFLUX_TEST_ENABLED)
  • CI green

Four version-independent bugs, none previously covered:

- handleWriteError drops InfluxDB's response body on the write path for
  400/401/403/413/422, has no 503 arm, and renders parsed JSON bodies as
  [object Object] (write-error-core.test.ts, write-error-cloud.test.ts).
  Mirrors the query-error-core.test.ts pattern; handleQueryError already
  does this correctly.
- write routing per product type was untested (write-routing.test.ts):
  which endpoint/transport each product type uses, and that an unknown
  product type rejects rather than silently defaulting.
- zod is imported at runtime throughout src/tools/ but declared only in
  devDependencies, so a clean `npm i --omit=dev` breaks (packaging.test.ts).
- ping()'s x-influxdb-version/x-influxdb-build header passthrough was
  untested (base-connection-ping.test.ts).
- protocol-write.test.ts covers write_line_protocol's advertised schema,
  error surfacing over the protocol boundary, and health_check's
  hasAnySuccess bug (a constructed client reports HEALTHY even when both
  /ping and /health fail).

test:integration now matches any *integration* test file instead of only
integration.test.ts — query-error-integration.test.ts was never actually
wired into the live-instance run.

Several `describe.skip("[P<n>] ...")` blocks are acceptance criteria for
fixes not yet implemented; each is paired with an active test asserting
today's (wrong) behavior, so implementing the fix flips both at once.

Split off a broader InfluxDB 3.11 compatibility pass: the version-gated
parts (live-instance tests, the 3.11 tool-surface guardrail, open
questions) moved to the influxdb-3.11-compat-patch branch instead.
Two of three guessed response shapes for a duplicate-tag-key write
rejection never occur. Verified live against both Core (3.11.0-nightly)
and Enterprise (3.11.0-0.rc.1, --upgrade-pacha-tree): a duplicate tag
key is always reported under data[].error_message inside the
partial-write body, byte-for-byte identical on both builds. Neither
data.error nor data.message carries it.

- Delete CORE_400_DUPLICATE_TAG_UNDER_ERROR and
  CORE_400_DUPLICATE_TAG_UNDER_MESSAGE; they don't represent real
  responses.
- Update CORE_400_DUPLICATE_TAG_UNDER_PARTIAL_DATA with the actual
  wording ("invalid line protocol - multiple instances of 'region' tag
  found") and InfluxDB's own truncated original_line; promote from
  PROVISIONAL to RECORDED.
- write-error-core.test.ts: drop the it.each over three shapes down to
  the one real shape; fix the /duplicate/i assertions in the [P1]
  acceptance block to the real wording; fold [P1/A2] into [P1] now that
  A2 is answered rather than leaving a separate blocked-on-A2 block.
- tests/README.md: table column alignment per prettier.
- query-error-integration.test.ts asserted Core's "database not found"
  wording unconditionally. It was previously dead in CI (test:integration
  only matched integration.test.ts), so this never ran. Now that it
  runs, it also executes under the cloud-serverless CI job, which
  reports the same condition as "bucket ... not found" (v2-lineage
  vocabulary). Both wordings verified against real CI runs on this PR:
  Core job passed with "database not found", serverless job failed
  with the real "bucket ... not found" text. Pick the expected pattern
  by INFLUX_DB_PRODUCT_TYPE instead of hardcoding Core's wording.
@jstirnaman
jstirnaman temporarily deployed to cloud-serverless July 28, 2026 19:09 — with GitHub Actions Inactive
@jstirnaman
jstirnaman enabled auto-merge July 28, 2026 19:10
Comments referenced alphanumeric codes (P1-P7, A1-A4, "impact map 1.1")
from a planning document that now lives only on the
influxdb-3.11-compat-patch branch, not this one. A reader of this
branch had no way to resolve what "P2" or "A2" meant. Replaced with
plain, self-contained descriptions of the same technical content;
renamed the matching describe.skip() block titles to drop the [P<n>]
tags.

Also fixes a factual error in write-routing.test.ts and
fixtures/write-errors.ts: the "InfluxDB 3.11 notes document a 400->503
change for /api/v2/write, which only the clustered product type uses"
framing conflated two unrelated facts. The Core/Enterprise-scoped 3.11
release notes describe a legacy v1/v2 write endpoint that Core/
Enterprise themselves also expose for backward compatibility - not
`InfluxProductType.Clustered`, a separate product (InfluxDB Clustered,
grouped with Cloud Dedicated per src/config.ts:98-105) on its own
release train that happens to also call /api/v2/write for unrelated
reasons. This server never calls the legacy endpoint for Core/
Enterprise regardless; it always uses /api/v3/write_lp.
@jstirnaman
jstirnaman temporarily deployed to cloud-serverless July 28, 2026 19:37 — with GitHub Actions Inactive
@jstirnaman
jstirnaman added this pull request to the merge queue Jul 28, 2026
Merged via the queue into main with commit d71d780 Jul 28, 2026
5 checks passed
@jstirnaman
jstirnaman deleted the claude/influxdb3-mcp-server-tests-f6irxy branch July 28, 2026 22:33
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.

2 participants