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

json-output: Fix unknowns for tuples and sets #31236

Merged
merged 1 commit into from Jun 17, 2022

Conversation

alisdair
Copy link
Member

The JSON output for sequences previously omitted unknown values for tuples and sets, which made it impossible to interpret the corresponding unknown marks. For example, consider this resource:

resource "example_resource" "example" {
  tags = toset(["alpha", timestamp(), "charlie"])
}

This would previously be encoded in JSON as:

"after": {
    "tags": ["alpha", "charlie"]
},
"after_unknown": {
    "id": true,
    "tags": [false, true, false]
},

That is, the timestamp value would be omitted from the output altogether, while the corresponding unknown marks would include a value for each of the set members.

This commit changes the behaviour to:

"after": {
    "tags": ["alpha", null, "charlie"]
},
"after_unknown": {
    "id": true,
    "tags": [false, true, false]
},

This aligns tuples and sets with the prior behaviour for lists, and makes it clear which elements are known and which are unknown.

I consider this a bug fix, as the prior output was not usable, and I believe this behaviour is correct.

The JSON output for sequences previously omitted unknown values for
tuples and sets, which made it impossible to interpret the corresponding
unknown marks. For example, consider this resource:

    resource "example_resource" "example" {
      tags = toset(["alpha", timestamp(), "charlie"])
    }

This would previously be encoded in JSON as:

    "after": {
        "tags": ["alpha", "charlie"]
    },
    "after_unknown": {
        "id": true,
        "tags": [false, true, false]
    },

That is, the timestamp value would be omitted from the output
altogether, while the corresponding unknown marks would include a value
for each of the set members.

This commit changes the behaviour to:

    "after": {
        "tags": ["alpha", null, "charlie"]
    },
    "after_unknown": {
        "id": true,
        "tags": [false, true, false]
    },

This aligns tuples and sets with the prior behaviour for lists, and
makes it clear which elements are known and which are unknown.
Copy link
Member

@cam-stitt cam-stitt left a comment

Choose a reason for hiding this comment

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

Makes sense!

@alisdair alisdair merged commit 7fcf973 into main Jun 17, 2022
@github-actions
Copy link

Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch.

@alisdair alisdair deleted the alisdair/json-plan-fix-tuple-set-unknown branch June 17, 2022 15:50
@github-actions
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 Jul 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants