{
  "slug": "packer-hcl2-object-variables-support-optional-attributes-526fe7bb5585",
  "title": "Packer HCL2 object variables support optional attributes",
  "tools": [
    "packer"
  ],
  "tags": [
    "agent"
  ],
  "introduced_at": "2026-07-24T09:26:22.000Z",
  "announced_at": "2026-07-24T09:26:22.000Z",
  "effective_at": null,
  "date_basis": "source-publication",
  "status": "unknown",
  "how": {
    "incantation": "When an object variable attribute may be omitted, declare it with `optional(<TYPE>, <DEFAULT>)`; Packer uses its default when the field is omitted.",
    "examples": [
      "variable \"<name>\" {\n  type = object({\n    <attribute> = optional(<TYPE>, <DEFAULT>)\n  })\n}"
    ],
    "gotchas": [
      "Version: v1.16.0",
      "optional(<TYPE>, <DEFAULT>): Marks an object type attribute as optional and supplies its default when omitted.",
      "Prerequisite: Use Packer v1.16.0 or later; this feature is stated in the v1.16.0 release notes.",
      "Omitted fields are supported when they have a default set."
    ]
  },
  "why_it_matters": "When declaring a Packer object variable with attributes that may be omitted, assign defaults to those attributes with `optional()`.",
  "sources": [
    "https://github.com/hashicorp/packer/releases/tag/v1.16.0",
    "https://developer.hashicorp.com/packer/docs/templates/hcl_templates/variables"
  ],
  "rank": 0.99039,
  "judge": {
    "publish": true,
    "judge_model": "codex-cli/gpt-6-luna+typesafe/jev-1.13.0",
    "prompt_version": "extract-v7+enrich-v2+judge-v2x3+jev-publish-v1"
  },
  "review_state": "approved",
  "provenance": {
    "run_id": "wave1-20261014",
    "verdict_id": "wave1-20261014:wave1-20261014-9c51c9cc7a7f1cd2-3:gate",
    "evidence_hash": "72ab0ab6b1a0f442592bc7154d62d6e5c5a1ebe208574ec7804eb9c8e288feeb"
  },
  "review": {
    "draft_hash": "b76c0df7ea080539c63a01ba58d594815d7cb45fd023c0ff14f8e81763e71c9d",
    "reviewer": "publication-gate",
    "reviewed_at": "2026-10-07T00:00:00.000Z",
    "decision": "wave1-20261014:gate",
    "reason": "3 of 3 judge runs approved with p_yes >= 0.9 (mean 0.99 >= 0.9; 2 needed) and Jev gave 0.66 (>= 0.6 needed)."
  }
}
