Skip to content

calling setting up defer fn before checking error to prevent panic#1309

Merged
Uk1288 merged 1 commit intomainfrom
check-error-before-cleanup
Apr 14, 2026
Merged

calling setting up defer fn before checking error to prevent panic#1309
Uk1288 merged 1 commit intomainfrom
check-error-before-cleanup

Conversation

@Uk1288
Copy link
Copy Markdown
Contributor

@Uk1288 Uk1288 commented Apr 13, 2026

Description

Some tests was setting up defer fn before checking error which caused panic when actual errors happended. This panics would mask the actual error. Checking for error before defer function ensures there is no attempt to dereference nil values.

Testing plan

Run Automated tests

External links

Output from tests

Including output from tests may require access to a TFE instance. Ignore this section if you have no environment to test against.

$ TFE_ADDRESS="https://example" TFE_TOKEN="example" go test ./... -v -run TestFunctionsAffectedByChange

...

Rollback Plan

Changes to Security Controls

@Uk1288 Uk1288 requested a review from a team as a code owner April 13, 2026 23:47
@Uk1288 Uk1288 added the no-changelog-needed check changelog entry github workflow label Apr 13, 2026
@datadog-terraform-cloud-hashicorp
Copy link
Copy Markdown

datadog-terraform-cloud-hashicorp Bot commented Apr 13, 2026

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 8f3f793 | Docs | Was this helpful? Give us feedback!

@Uk1288 Uk1288 merged commit 8676430 into main Apr 14, 2026
16 of 17 checks passed
@Uk1288 Uk1288 deleted the check-error-before-cleanup branch April 14, 2026 15:10
@github-actions
Copy link
Copy Markdown

Reminder to the contributor that merged this PR: if your changes have added important functionality or fixed a relevant bug, open a follow-up PR to update CHANGELOG.md with a note on your changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog-needed check changelog entry github workflow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants