# Copyright (c) The OpenTofu Authors
# SPDX-License-Identifier: MPL-2.0
# Copyright (c) 2023 HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

name: Bug Report
description: Let us know about an unexpected error, a crash, or an incorrect behavior.
labels: ["bug", "pending-decision"]
body:
  - type: markdown
    attributes:
      value: |
        # Thank you for opening an issue.
        
        The [OpenTofu](https://github.com/opentofu/opentofu) issue tracker is reserved for bug reports relating to the core OpenTofu CLI application and configuration language.
        
        ## Filing a bug report
        
        To fix problems, we need clear reproduction cases - we need to be able to see it happen locally. A reproduction case is ideally something any engineer can git-clone or copy-paste and run immediately, without inventing any details or context.
        
        * A short example can be directly copy-pasteable; longer examples should be in separate git repositories, especially if multiple files are needed
        * Please include all needed context. For example, if you figured out that an expression can cause a crash, put the expression in a variable definition or a resource
        * Set defaults on (or omit) any variables. The person reproducing it should not need to invent variable settings
        * If multiple steps are required, such as running tofu twice, consider scripting it in a simple shell script. Providing a script can be easier than explaining what changes to make to the config between runs.
        * Omit any unneeded complexity: remove variables, conditional statements, functions, modules, providers, and resources that are not needed to trigger the bug
  - type: textarea
    id: community-note
    attributes:
      label: Community note
      description: Please leave this note unchanged.
      value: |
        > [!TIP]
        > 👋 Hi there, OpenTofu community! The OpenTofu team prioritizes issues based on upvotes. Please make sure to upvote this issue and describe how it affects you in detail in the comments to show your support.
  - type: textarea
    id: tf-version
    attributes:
      label: OpenTofu Version
      description: Run `tofu version` to show the version, and paste the result below. If you are not running the latest version of OpenTofu, please try upgrading because your issue may have already been fixed.
      render: shell
      placeholder: ...output of `tofu version`...
      value:
    validations:
      required: true

  - type: textarea
    id: tf-config
    attributes:
      label: OpenTofu Configuration Files
      description: Paste the relevant parts of your OpenTofu configuration between the ``` marks below. For OpenTofu configs larger than a few resources, or that involve multiple files, please make a GitHub repository that we can clone, rather than copy-pasting multiple files in here.
      placeholder:
      value: |
        ```hcl
        ...tofu config...
        ```
    validations:
      required: true

  - type: textarea
    id: tf-debug
    attributes:
      label: Debug Output
      description: |
        Full debug output can be obtained by running OpenTofu with the environment variable `TF_LOG=trace`.
        Please create a GitHub Gist containing the debug output. Please do _not_ paste the debug output in the issue,
        since debug output is long. Debug output may contain sensitive information.
        
        **⚠ Warning!** Carefully inspect the `TRACE` level OpenTofu logs! They may contain sensitive credentials.
        When in doubt, you can omit posting the logs and provide information later.
      placeholder: ...link to gist...
      value:
    validations:
      required: true
  - type: textarea
    id: tf-expected
    attributes:
      label: Expected Behavior
      description: What should have happened?
      placeholder: What should have happened?
      value:
    validations:
      required: true
  - type: textarea
    id: tf-actual
    attributes:
      label: Actual Behavior
      description: What actually happened?
      placeholder: What actually happened?
      value:
    validations:
      required: true
  - type: textarea
    id: tf-repro-steps
    attributes:
      label: Steps to Reproduce
      description: |
        Please list the full steps required to reproduce the issue, for example:
          1. `tofu init`
          2. `tofu apply`
      placeholder: |
        1. `tofu init`
        2. `tofu apply`
      value:
    validations:
      required: true
  - type: textarea
    id: tf-add-context
    attributes:
      label: Additional Context
      description: |
        Are there anything atypical about your situation that we should know?
        For example: is OpenTofu running in a wrapper script or in a CI system? Are you passing any unusual command line options or environment variables to opt-in to non-default behavior?"
      placeholder: Additional context...
      value:
    validations:
      required: false
  - type: textarea
    id: tf-references
    attributes:
      label: References
      description: |
        Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:
        ```
          - #1
        ```
      placeholder:
      value:
    validations:
      required: false

  - type: markdown
    attributes:
      value: |
        **Note:** If the submit button is disabled and you have filled out all required fields, please check that you did not forget a **Title** for the issue.
