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

Proper validation of empty string value in identity_type #1980

Merged
merged 1 commit into from
Jan 16, 2024

Conversation

viliampucik
Copy link
Contributor

This is continuation of #1978.

Because the logical operators (||, &&) in Terraform do not short-circuit, and coalesce() never returns non-empty string, empty string validation needs to be done differently.

The provided code change properly validates if identity_type is null or empty string or any of the allowed keywords.


Checklist

I applicable, I acknowledge that I have:

  • Read the contributing guide
  • Ran terraform fmt on all modified files
  • Regenerated the relevant README.md files using tools/tfdoc.py
  • Made sure all relevant tests pass

Copy link
Collaborator

@ludoo ludoo left a comment

Choose a reason for hiding this comment

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

Thanks for this.

Nit: I did not check but from memory contains([null, "", ...]) might also work.

@ludoo ludoo merged commit 5372361 into GoogleCloudPlatform:master Jan 16, 2024
9 checks passed
@viliampucik
Copy link
Contributor Author

contains() would fail if its last argument would be null:

contains([null, "", "a", "b"], null)
╷
│ Error: Invalid function argument
│
│   on <console-input> line 1:
│   (source code not available)
│
│ Invalid value for "value" parameter: argument must not be null.

@ludoo
Copy link
Collaborator

ludoo commented Jan 16, 2024

contains() would fail if its last argument would be null:

contains([null, "", "a", "b"], null)
╷
│ Error: Invalid function argument
│
│   on <console-input> line 1:
│   (source code not available)
│
│ Invalid value for "value" parameter: argument must not be null.

Thanks for correcting me, you're absolutely right :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants