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

function/stdlib: Fix panic with unknown set values #59

Merged
merged 1 commit into from Jun 23, 2020

Conversation

alisdair
Copy link
Contributor

@alisdair alisdair commented Jun 22, 2020

The fix for set unification recently introduced a bug with unknown set values which would cause a panic (hashicorp/terraform#25318). This was triggered by calling LengthInt on an unknown collection.

This commit fixes this by first verifying that the argument is known, so that calling its length is safe. If the argument is not known, it could be of any length, so we do not want to omit its element type from the set to be unified.

Includes regression tests.

Fixes hashicorp/terraform#25318

The fix for set unification recently introduced a bug with unknown set
values which would cause a panic. This was triggered by calling
LengthInt on an unknown collection.

This commit fixes this by first verifying that the argument is known, so
that calling its length is safe. If the argument is not known, it could
be of any length, so we do not want to omit its element type from the
set to be unified.

Includes regression tests.
@codecov
Copy link

codecov bot commented Jun 22, 2020

Codecov Report

Merging #59 into master will decrease coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #59      +/-   ##
==========================================
- Coverage   70.73%   70.70%   -0.03%     
==========================================
  Files          79       79              
  Lines        7176     7176              
==========================================
- Hits         5076     5074       -2     
- Misses       1659     1661       +2     
  Partials      441      441              
Impacted Files Coverage Δ
cty/function/stdlib/set.go 69.23% <100.00%> (ø)
cty/convert/compare_types.go 97.61% <0.00%> (-2.39%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 98cf8ce...95e6953. Read the comment docs.

@apparentlymart apparentlymart merged commit 07d966a into zclconf:master Jun 23, 2020
@alisdair alisdair deleted the fix-set-operation-panics branch June 23, 2020 17:47
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.

Panic with setunion() on variable input
2 participants