Skip to content

Parse a float32 at 32 bits so out-of-range input is rejected - #3401

Merged
knative-prow[bot] merged 1 commit into
knative:mainfrom
arpitjain099:fix/float32-parse-bit-size
Oct 21, 2026
Merged

knative-prow[bot] merged 1 commit into
knative:mainfrom
arpitjain099:fix/float32-parse-bit-size

Conversation

@arpitjain099

Copy link
Copy Markdown
Contributor

Follow-up to #3395, same copy-paste in the layer underneath. parse passes the target's own bit size to strconv for every sized type except float32, which parses at 64 and then narrows with a Go conversion:

case float32:
    val, err = strconv.ParseFloat(s, 64)
    val = float32(val.(float64))

A conversion has no error channel, so input outside float32's range is accepted with err == nil and stored as ±Inf. int16, uint16, int32 and float64 all 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: strconv returns ErrRange on overflow and not on underflow, so 1e-50 still parses to 0, and 3.4e38 just under the max still parses.

Four rows added to TestParse. 1e39 and -3.5e38 fail on main, where they currently come back as +Inf and -Inf with no error. The foo and 1e-50 rows pass either way. go test ./configmap/... is green.

Worth saying plainly: nothing in tree calls As[float32] today, same as AsUint64 when #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.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
@knative-prow knative-prow Bot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 15, 2026
@knative-prow

knative-prow Bot commented Oct 15, 2026

Copy link
Copy Markdown

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions 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.

@knative-prow
knative-prow Bot requested review from Leo6Leo and creydr October 15, 2026 13:55
@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.31%. Comparing base (0795cb8) to head (2e9dcfe).
⚠️ Report is 3 commits behind head on main.

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.
📢 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.

@dsimansk

Copy link
Copy Markdown
Contributor

/ok-to-test

@knative-prow knative-prow Bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 20, 2026
@dsimansk

Copy link
Copy Markdown
Contributor

/approve
/lgtm

@knative-prow knative-prow Bot added the lgtm Indicates that a PR is ready to be merged. label Oct 21, 2026
@knative-prow

knative-prow Bot commented Oct 21, 2026

Copy link
Copy Markdown

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 21, 2026
@knative-prow
knative-prow Bot merged commit efa6bf3 into knative:main Oct 21, 2026
38 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants