Repository navigation
Parse a float32 at 32 bits so out-of-range input is rejected - #3401
Conversation
Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
|
Hi @arpitjain099. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3401 +/- ##
==========================================
+ Coverage 75.28% 75.31% +0.02%
==========================================
Files 189 189
Lines 8360 8360
==========================================
+ Hits 6294 6296 +2
+ Misses 1823 1822 -1
+ Partials 243 242 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
/ok-to-test |
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: arpitjain099, dsimansk The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Follow-up to #3395, same copy-paste in the layer underneath.
parsepasses the target's own bit size tostrconvfor every sized type exceptfloat32, which parses at 64 and then narrows with a Go conversion:A conversion has no error channel, so input outside float32's range is accepted with
err == niland stored as±Inf.int16,uint16,int32andfloat64all reject out-of-range input, so float32 is the odd one out rather than a deliberate choice.ParseFloat(s, 32)returns the nearest float32 widened to float64, so line 96 still works. It also only tightens the overflow case:strconvreturnsErrRangeon overflow and not on underflow, so1e-50still parses to 0, and3.4e38just under the max still parses.Four rows added to
TestParse.1e39and-3.5e38fail on main, where they currently come back as+Infand-Infwith no error. Thefooand1e-50rows pass either way.go test ./configmap/...is green.Worth saying plainly: nothing in tree calls
As[float32]today, same asAsUint64when #3395 went in, so this is a fix to a supported exported type rather than to a live bug.AI assistance was used on this change and is disclosed in the commit trailer.