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

Misleading diagnostics "Attribute required" for attributes with defaults #1616

Open
radeksimko opened this issue Oct 31, 2023 · 2 comments
Open
Labels
bug Something isn't working diagnostics

Comments

@radeksimko
Copy link
Member

Background

This is more of a meta issue describing a problem with "required-ness" of attributes, which was originally reported in

Currently, we produce diagnostics for any attribute which is marked as "required" in the [JSON] provider schema. This is often correct in the simple cases, e.g. value in the output block:
Screenshot 2023-10-31 at 10 53 50

However, it is incorrect/misleading in more complex cases, typically in provider blocks, which frequently get configured via environment variables:

Screenshot 2023-10-31 at 10 55 13 Screenshot 2023-10-31 at 10 56 05

The distinction between "just required" and "required if not supplied as environment variable" is currently embedded in the providers, as can be shown for the two cases above:

Unfortunately, this distinction (the existence of a possible default) is not surfaced in an accessible way - i.e. it's not part of the JSON machine-readable schema (terraform providers schema -json) we use to inform the validation.

Proposal

  • Consider disabling validation of required attributes
  • Consider Make individual validators configurable #1605 (perhaps with required attribute validator disabled by default for now)
  • Plan what we can do to enable reliable validation (e.g. have providers expose the defaults somehow)
@dbanck
Copy link
Member

dbanck commented Nov 8, 2023

We released a partial bug fix for provider blocks in 2.29.0.

I'm keeping this issue open in case anyone encounters this problem with other block types.

@radeksimko radeksimko removed their assignment Nov 8, 2023
@ndrpnt
Copy link

ndrpnt commented Dec 11, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working diagnostics
Projects
None yet
Development

No branches or pull requests

3 participants