这是indexloc提供的服务,不要输入任何密码
Skip to content

Omit null environment variables in vercel_deployment #96

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

Merged
merged 1 commit into from
Jan 6, 2023

Conversation

dglsparsons
Copy link
Collaborator

Creating a vercel_deployment and passing a null environment variable results in a conversion error.

An unexpected error was encountered trying to build a value. This is always
an error in the provider. Please report the following to the provider
developer:

Received null value, however the target type cannot handle null values. Use
the corresponding `types` package type, a pointer type or a custom type that
handles null values.

Path: ["BAZ"]
Target Type: string
Suggested `types` Type: basetypes.StringValue
Suggested Pointer Type: *string

We need to handle the case where the field value is null, which is currently omitted.

Since the API only accepts string values for enviroment variables, the best solution is to simply omit sending null to the API altogether.

Closes #95

Creating a vercel_deployment and passing a `null` environment variable
results in a conversion error.
```
An unexpected error was encountered trying to build a value. This is always
an error in the provider. Please report the following to the provider
developer:

Received null value, however the target type cannot handle null values. Use
the corresponding `types` package type, a pointer type or a custom type that
handles null values.

Path: ["BAZ"]
Target Type: string
Suggested `types` Type: basetypes.StringValue
Suggested Pointer Type: *string
```

We need to handle the case where the field value is `null`, which is
currently omitted.

Since the API only accepts string values for enviroment variables, the
best solution is to simply omit sending `null` to the API altogether.

Closes #95
@@ -109,7 +109,8 @@ func TestAcc_DeploymentWithEnvironment(t *testing.T) {
{
Config: testAccDeploymentConfig(projectSuffix, teamIDConfig(), `environment = {
FOO = "baz",
BAR = "qux"
BAR = "qux",
BAZ = null

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to check that BAZ is not present on the output? I suppose this test would fail otherwise.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test failed before the changes b/c of the deserialization issue. It's a bit rubbish but the test helpers don't give a nice way to check for a null value on the output. I think just checking that it doesn't cause the provider to panic is as good as we can do (which is the purpose of this).

@dglsparsons dglsparsons merged commit 444b61f into main Jan 6, 2023
@dglsparsons dglsparsons deleted the fix-null-env branch January 6, 2023 18:22
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.

Optional environment variable using null value
3 participants