Skip to content

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

Merged
karel-rehor merged 2 commits into
mainfrom
fix/v2-precision-format
Oct 2, 2026
Merged

karel-rehor merged 2 commits into
mainfrom
fix/v2-precision-format

Conversation

@karel-rehor

@karel-rehor karel-rehor commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

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)

Note

Changes and issue were first submitted in #60, however user Iqleon1214 failed to sign CLA. To speed things up, decided to move these changes to a repository branch.

@karel-rehor karel-rehor changed the title fix: use correct precision format for v2 write API- #60 fix: use correct precision format for v2 write API Oct 1, 2026
@karel-rehor
karel-rehor requested a balanced review from Copilot October 2, 2026 07:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The implementation correctly addresses the protocol mismatch with comprehensive focused coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes precision formatting for InfluxDB v2 write requests.

Changes:

  • Adds v2 short precision strings.
  • Selects precision format by write API version.
  • Adds unit, mock HTTP, and end-to-end coverage.
File Description
src/​precision.rs Adds v2 precision formatting and tests.
src/​client.rs Uses endpoint-appropriate precision parameters.
tests/​write_tests.rs Verifies v2 HTTP query parameters.
tests/​client.rs Adds v2 precision end-to-end coverage.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@codecov-commenter

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 (8de9e75).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #69      +/-   ##
==========================================
+ 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.

@alespour alespour left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍

@karel-rehor
karel-rehor merged commit 4692deb into main Oct 2, 2026
13 checks passed
@karel-rehor
karel-rehor deleted the fix/v2-precision-format branch October 2, 2026 08:47
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.

4 participants