Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tftypes: Return null Number when NewValue receives (*big.Float)(nil) #114

Merged
merged 1 commit into from
Oct 5, 2021

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Oct 5, 2021

Reference: hashicorp/terraform-plugin-framework#89

This matches the consistency of other pointer types in the valueFromNumber function and can prevent unexpected panics.

Reference: hashicorp/terraform-plugin-framework#89

This matches the consistency of other pointer types in the `valueFromNumber` function and can prevent unexpected panics.
@bflad bflad added the bug Something isn't working label Oct 5, 2021
@bflad bflad requested a review from a team October 5, 2021 19:50
@bflad bflad added this to the v0.5.0 milestone Oct 5, 2021
@bflad bflad merged commit fee1e53 into main Oct 5, 2021
@bflad bflad deleted the bflad-b-tftypes-nil-big-Float branch October 5, 2021 19:54
bflad added a commit that referenced this pull request Oct 5, 2021
bflad added a commit to hashicorp/terraform-plugin-framework that referenced this pull request Oct 5, 2021
Reference: #89
Reference: hashicorp/terraform-plugin-go#114

This change will ensure that if the `Number` `Value` pointer is `nil`, that the returned value is an untyped `nil`, rather than a `*big.Float` typed `nil`.

The upstream `(tftypes.Value).IsNull()` method can only detect untyped `nil` for values. A related fix for `tftypes.NewValue()` to convert a `*big.Float` `nil` value into an untyped `nil` has also been merged upstream to fix this in depth.

Previously, this new test case would pass:

```go
		"value-nil": {
			input:       Number{Value: nil},
			expectation: (*big.Float)(nil),
		},
```

Now it appropriately expects:

```go
		"value-nil": {
			input:       Number{Value: nil},
			expectation: nil,
		},
```
bflad added a commit to hashicorp/terraform-plugin-framework that referenced this pull request Oct 5, 2021
Reference: #89
Reference: hashicorp/terraform-plugin-go#114

This change will ensure that if the `Number` `Value` pointer is `nil`, that the returned value is an untyped `nil`, rather than a `*big.Float` typed `nil`.

The upstream `(tftypes.Value).IsNull()` method can only detect untyped `nil` for values. A related fix for `tftypes.NewValue()` to convert a `*big.Float` `nil` value into an untyped `nil` has also been merged upstream to fix this in depth.

Previously, this new test case would pass:

```go
		"value-nil": {
			input:       Number{Value: nil},
			expectation: (*big.Float)(nil),
		},
```

Now it appropriately expects:

```go
		"value-nil": {
			input:       Number{Value: nil},
			expectation: nil,
		},
```
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants