Skip to content

test: regression guard for IPv6 strings mishandled by !terraform.state#2156

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-ipv6-string-handling
Draft

test: regression guard for IPv6 strings mishandled by !terraform.state#2156
Copilot wants to merge 3 commits intomainfrom
copilot/fix-ipv6-string-handling

Conversation

Copy link
Contributor

Copilot AI commented Mar 9, 2026

IPv6 addresses ending in :: (e.g., 2041:0000:140F::875B::) were silently converted to {"2041:0000:140F::875B:": null} in terraform.tfvars.json, causing Terraform to reject the value because the variable was declared as string. The bug was present through v1.204.0 and fixed in v1.206.0 (PR #2059) as a side-effect of ARN colon-handling — but IPv6 had no test coverage.

Changes

  • pkg/utils/yq_utils.go — updated comments on isScalarString, isMisinterpretedScalar, and keyMatchesOriginalWithColon to explicitly name IPv6 alongside ARNs and reference the fix version (v1.206.0 / PR fix: YAML strings ending with colons parsed incorrectly #2059)

  • pkg/utils/yq_utils_test.go — added IPv6 cases to TestIsScalarString, TestIsMisinterpretedScalar, and TestEvaluateYqExpression_ARNWithTrailingColons; new TestEvaluateYqExpression_IPv6Scenario exercises individual values, maps of addresses, and nested extraction

  • internal/exec/yaml_func_terraform_state_yq_defaults_test.go — new TestTerraformState_IPv6StringPreserved exercises the full !terraform.state pipeline via mock for ::, 2001:db8::, 2041:0000:140F::875B::, ::1, and 2001:db8::1

  • internal/exec/yaml_func_terraform_state_test.go + fixtures — integration subtest "IPv6 address string preservation" using component-ipv6-sourcecomponent-ipv6-consumer; added ipv6 var/output to the mock Terraform component

# Previously broken — dummy2 received {"2041:0000:140F::875B:": null}
components:
  terraform:
    dummy1:
      vars:
        ipv6: "2041:0000:140F::875B::"
    dummy2:
      vars:
        ipv6: !terraform.state dummy1 ipv6   # now correctly preserved as string

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.bitbucket.org
    • Triggering command: /tmp/go-build1991828671/b001/utils.test /tmp/go-build1991828671/b001/utils.test -test.paniconexit0 -test.count=1 -test.timeout=2m0s /tmp/go-build1991828671/b1274/vet.cfg 6793371/b1186/ve-errorsas .cfg ux-amd64/pkg/tool/linux_amd64/vet /bubbles@v1.0.0//home/REDACTED/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.26.0.linux-amd64/pkg/too/tmp/go-build1991828671/b1240/vet.cfg (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>terraform.state mishandles some ipv6 strings</issue_title>
<issue_description>### Describe the Bug

When a Terraform module outputs an IPv6 string ending in a double colon ::, !terraform.state mishandles the string, converting it into an object where part of the ipv6 is the key, and null is the value.

E.g. 2041:0000:140F::875B:: becomes "2041:0000:140F::875B:": null

Expected Behavior

!terraform.state should preserve the string type on an output that ends in double colons.

Steps to Reproduce

Set up a dummy terraform_data component, and instantiate it twice like so (I used examples/quick-start-start-simple):

# components/terraform/dummy/main.tf
variable "ipv6" {
  type        = string
  description = "The IPv6 address"
}

resource "terraform_data" "this" {
  input = var.ipv6
}

output "ipv6" {
  value       = terraform_data.this.output
  description = "An IPv6 output"
}
# stacks/deploy/dev.yaml
components:
  terraform:
    dummy1:
      metadata:
        component: dummy
      vars:
        ipv6: "2041:0000:140F::875B::"
    dummy2:
      metadata:
        component: dummy
      vars:
        ipv6: !terraform.state dummy1 ipv6

atmos terraform apply -s dev dummy1 applies successfully.
atmos terraform apply -s dev dummy2 returns error.

│ Error: Invalid value for input variable
│ 
│   on dev-dummy2.terraform.tfvars.json line 2:
│    2:   "ipv6": {
│    3:     "2041:0000:140F::875B:": null
│    4:   },
│ 
│ The given value is not suitable for var.ipv6 declared at main.tf:1,1-16: string required, but have object.
╵

Screenshots

No response

Environment

  • OS darwin/arm64
  • Atmos 1.204.0

Additional Context

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@mergify mergify bot added triage Needs triage wip Work in Progress: Not ready for final review or merge labels Mar 9, 2026
…2155)

Co-authored-by: osterman <52489+osterman@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix handling of IPv6 strings in terraform.state test: Add IPv6 string preservation regression tests for !terraform.state Mar 9, 2026
@mergify mergify bot removed the wip Work in Progress: Not ready for final review or merge label Mar 9, 2026
@osterman osterman added the patch A minor, backward compatible change label Mar 11, 2026
@github-actions github-actions bot added the size/m Medium size PR label Mar 11, 2026
@github-actions
Copy link

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Files

None

… comments

Co-authored-by: osterman <52489+osterman@users.noreply.github.com>
Copilot AI changed the title test: Add IPv6 string preservation regression tests for !terraform.state test: regression guard for IPv6 strings mishandled by !terraform.state Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch A minor, backward compatible change size/m Medium size PR triage Needs triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

terraform.state mishandles some ipv6 strings

2 participants