Skip to content

write.service.ts discards server error detail for most HTTP status codes #32

@jstirnaman

Description

@jstirnaman

Problem

handleWriteError in src/services/write.service.ts throws hardcoded error messages for 400/401/403/413/422 status codes, discarding the actual InfluxDB error detail from the response body.

For example, Core returns detailed 400 errors for bad writes:

{"error":"partial write of line protocol occurred","data":[{"error_message":"No fields were provided","line_number":1}]}

But the handler throws only:

Bad request: Invalid line protocol format or parameters

The real error detail (which lines failed, why) is lost.

Expected behavior

The server error message should be surfaced in the thrown error, matching the pattern used in handleQueryError and the other service error handlers:

const serverMessage =
  error.response?.data?.message ||
  error.response?.data?.error ||
  (typeof error.response?.data === "string" ? error.response.data : null) ||
  error.response?.statusText;

Affected code

src/services/write.service.ts lines 194-213 (handleWriteError)

Context

Found during error handling audit in PR #31. The other 4 services have been fixed to surface all error formats (JSON {error:...}, JSON {message:...}, plain-text strings).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions