Skip to content

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

Merged
alisdair merged 1 commit intomainfrom
alisdair/json-plan-fix-tuple-set-unknown
Jun 17, 2022
Merged

json-output: Fix unknowns for tuples and sets#31236
alisdair merged 1 commit intomainfrom
alisdair/json-plan-fix-tuple-set-unknown

Conversation

@alisdair
Copy link
Copy Markdown
Contributor

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.
@alisdair alisdair requested review from a team and cam-stitt June 13, 2022 18:56
@alisdair alisdair self-assigned this Jun 13, 2022
Copy link
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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.

3 participants