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

Impossible condition in `modules/azure/recoveryservices.go#GetRecoveryServicesVaultBackupProtectedVMListE #1418

Closed
fkurz opened this issue Jul 9, 2024 · 0 comments · Fixed by #1419
Assignees
Labels
bug Something isn't working terratest

Comments

@fkurz
Copy link

fkurz commented Jul 9, 2024

Describe the bug

Line 122 in modules/azure/recoveryservices.go#GetRecoveryServicesVaultBackupProtect violates nilness: check for redundant or impossible conditions.

The condition err != nil in line 122 will always evaluate to false (due to the early exit in line 118). This implies that potential errors from the call to getTargetAuzureResourceGroupName (line 121) are ignored.

Supposedly, the condition should be err2 != nil .

To Reproduce
No reproducer. Found by statical analysis.

// GetRecoveryServicesVaultBackupProtectedVMListE returns a list of protected VM's on the given vault/policy.
func GetRecoveryServicesVaultBackupProtectedVMListE(policyName, vaultName, resourceGroupName, subscriptionID string) (map[string]backup.AzureIaaSComputeVMProtectedItem, error) {
	subscriptionID, err := getTargetAzureSubscription(subscriptionID)
	if err != nil { 
		return nil, err
	}

	resourceGroupName, err2 := getTargetAzureResourceGroupName(resourceGroupName)
	if err != nil { // <- always false 
		return nil, err2
	}

        // ...
}

Versions

  • Terratest version: v0.46.15
  • Environment details (Ubuntu 20.04, Windows 10, etc.):
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.2 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
@fkurz fkurz added the bug Something isn't working label Jul 9, 2024
@ZachGoldberg ZachGoldberg added the terratest label Jul 9, 2024 — with Linear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working terratest
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants