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

[synthetics_test] Handle request_file when state does not exist #2659

Merged
merged 1 commit into from
Nov 11, 2024

Conversation

skarimo
Copy link
Member

@skarimo skarimo commented Nov 11, 2024

During imports or manual edits of the synthetics test, the request_file content might not be in the state. To avoid panics, check if the map or map item is nil first.

Example stack trace:

Stack trace from the terraform-provider-datadog plugin:

panic: runtime error: index out of range [0] with length 0

goroutine 146 [running]:
github.com/terraform-providers/terraform-provider-datadog/datadog.buildTerraformBodyFiles(0x1400041a0a0, {0x102f02d20, 0x0, 0x1?})
	/dd/terraform-provider-datadog/datadog/resource_datadog_synthetics_test_.go:2882 +0x3bc
github.com/terraform-providers/terraform-provider-datadog/datadog.updateSyntheticsAPITestLocalState(0x14000bc4100, 0x1400041ab40)
	/dd/terraform-provider-datadog/datadog/resource_datadog_synthetics_test_.go:1867 +0x2264
github.com/terraform-providers/terraform-provider-datadog/datadog.resourceDatadogSyntheticsTestRead({0x10204e698?, 0x140008cb050?}, 0x14000bc4100, {0x101be8800?, 0x14000868750?})
	/dd/terraform-provider-datadog/datadog/resource_datadog_synthetics_test_.go:1470 +0x7e4
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x14000341ce0, {0x10204e698, 0x140008cb050}, 0x14000bc4100, {0x101be8800, 0x14000868750})

@skarimo skarimo requested review from a team as code owners November 11, 2024 21:34
@skarimo skarimo changed the title [synthetics_test] handle when state does not exist [synthetics_test] Handle request_file when state does not exist Nov 11, 2024
@skarimo skarimo merged commit a79bcaa into master Nov 11, 2024
13 checks passed
@skarimo skarimo deleted the sherz/handle-missing-file-from-state branch November 11, 2024 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants