Skip to content

Commit a6ae3c7

Browse files
fix(techops-19980): resolve float32 precision loss in stream start_range and end_range (#39)
# Fix: Resolve float32 precision loss in stream start_range and end_range ## Problem The provider was experiencing precision loss when handling large `start_range` and `end_range` values due to `float32` type conversion. This caused Terraform to report "Provider produced inconsistent result after apply" errors when values like `400990050` were converted to `400990048` due to `float32`'s limited precision (24-bit mantissa). ## Root Cause - OpenAPI specification defined `start_range` and `end_range` as `*float32` - `float32` can only precisely represent integers up to ~16,777,216 (2^24) - Large block numbers (400M+) exceeded this precision limit - Terraform detected the precision loss and flagged it as an inconsistency ## Solution Changed the API types from `*float32` to `*int64` for range fields: - `StartRange *float32` → `StartRange *int64` - `EndRange *float32` → `EndRange *int64` This eliminates precision loss while maintaining JSON compatibility since JSON numbers can represent large integers ## Benefits ✅ **Eliminates precision loss** - `int64` can precisely represent all blockchain block numbers ## Testing - ✅ Provider compiled successfully - ✅ Local testing with real QuickNode API - ✅ Tested with problematic values: `400990050`, `400990100`, `400990200`, `400990300` - ✅ Verified `terraform plan` shows no changes after operations - ✅ Confirmed create, update, and destroy operations work correctly ## Risks ⚠️ **OpenAPI specification mismatch** - If QuickNode API strictly requires `float32`, this may cause issues (testing shows it works) ⚠️ **Code regeneration** - Changes will be overwritten if `streams.gen.go` is regenerated from OpenAPI spec
1 parent cfce7c0 commit a6ae3c7

4 files changed

Lines changed: 37 additions & 34 deletions

File tree

0 commit comments

Comments
 (0)