Skip to content

fix: use correct precision format for v2 write API - #60

Open
lqleon1214 wants to merge 3 commits into
InfluxCommunity:mainfrom
lqleon1214:main
Open

lqleon1214 wants to merge 3 commits into
InfluxCommunity:mainfrom
lqleon1214:main

Conversation

@lqleon1214

Copy link
Copy Markdown

Closes #

Proposed Changes

Bug: Precision::as_str() returns the v3 format (nanosecond, microsecond, millisecond, second), but when the v2 API is selected (use_v2_api = true, targeting /api/v2/write), the server expects the short format (ns, us, ms, s). Previously send_lp always used as_str() regardless of v2 or v3, so the precision parameter was sent in the wrong format for v2 writes and could be rejected or misinterpreted by the server.

Fix:

  • Added Precision::as_v2_str() returning the v2 short-format strings
  • Updated send_lp to select the correct precision format based on use_v2_api:
    • use_v2_api = trueas_v2_str() (ns/us/ms/s)
    • use_v2_api = falseas_str() (nanosecond/microsecond/millisecond/second)
  • Added a unit test for as_v2_str() verifying all four precisions output correctly and round-trip through the v2 format

Checklist

  • CHANGELOG.md updated
  • Rebased/mergeable
  • A test has been added if appropriate
  • Tests pass
  • Commit messages are conventional
  • Sign CLA (if not already signed)

@alespour alespour changed the title fix: use correctfix: use correct precision format for v2 write API precision format for v2 write API fix: use correct precision format for v2 write API precision format for v2 write API Sep 6, 2026
@alespour alespour changed the title fix: use correct precision format for v2 write API precision format for v2 write API fix: use correct precision format for v2 write API Sep 6, 2026
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