Skip to content

fix(apiquery): encode float32 query values at float32 precision - #665

Open
latent-9 wants to merge 1 commit into
orbcorp:mainfrom
latent-9:fix/apiquery-float32-precision
Open

fix(apiquery): encode float32 query values at float32 precision#665
latent-9 wants to merge 1 commit into
orbcorp:mainfrom
latent-9:fix/apiquery-float32-precision

Conversation

@latent-9

@latent-9 latent-9 commented Aug 27, 2026

Copy link
Copy Markdown

internal/apiquery/encoder.go formats both reflect.Float32 and reflect.Float64 values with strconv.FormatFloat(..., 64), so float32 query parameters are serialized with float64 noise, e.g. 43.76 becomes 43.7599983215332. The sibling internal/apiform/encoder.go already splits the two kinds; this makes apiquery match. Query tests pinned to the noisy output are updated to the exact value.

Summary by CodeRabbit

  • Bug Fixes

    • Improved query serialization for 32-bit floating-point values.
    • Float32 values now retain appropriate precision instead of exposing excessive binary conversion digits.
    • Float64 serialization remains unchanged.
  • Tests

    • Updated query output expectations to reflect the corrected Float32 formatting.

@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: bd5d4f7a-5bfd-4b70-b5cf-21a43e743697

📥 Commits

Reviewing files that changed from the base of the PR and between e79818c and 297f58e.

📒 Files selected for processing (2)
  • internal/apiquery/encoder.go
  • internal/apiquery/query_test.go

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The query encoder now formats Float32 values with 32-bit precision. Query tests now expect the resulting 43.76 representation.

Changes

Float32 Query Encoding

Layer / File(s) Summary
Float32 formatting and validation
internal/apiquery/encoder.go, internal/apiquery/query_test.go
newPrimitiveTypeEncoder uses bit size 32 for reflect.Float32 and bit size 64 for reflect.Float64. Tests update the expected Float32 query value from 43.7599983215332 to 43.76.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 297f5

This localized change makes float32 query values serialize at float32 precision and updates the affected expectations; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: encoding float32 query values at float32 precision.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

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.

1 participant