Skip to content

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

Closed
lqleon1214 wants to merge 6 commits into
InfluxCommunity:mainfrom
lqleon1214:main
Closed

lqleon1214 wants to merge 6 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 = true → as_v2_str() (ns/us/ms/s)
    • use_v2_api = false → as_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
@codecov-commenter

codecov-commenter commented Oct 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.12%. Comparing base (a3232bf) to head (f695bb8).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #60      +/-   ##
==========================================
+ Coverage   83.97%   84.12%   +0.14%     
==========================================
  Files          10       10              
  Lines        2141     2161      +20     
==========================================
+ Hits         1798     1818      +20     
  Misses        343      343              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@karel-rehor
karel-rehor self-requested a review October 1, 2026 13:02
@karel-rehor

Copy link
Copy Markdown
Contributor

@lqleon1214

Thank you for your valuable contribution!

We would like to add this to the next release. However, you have not indicated that the CLA has been signed. This is a requirement for all contributions. In order to expedite these changes, we've copied them with a couple of extra tests into a branch of the main project. They will be merged in PR #69.

@karel-rehor karel-rehor closed this Oct 2, 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.

3 participants