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

Bug: Panic on asoctl import azure-resource with Role Assignment: Invalid Memory Address or Nil Pointer Dereference #4444

Closed
bertellil-prom opened this issue Nov 13, 2024 · 1 comment · Fixed by #4450
Assignees
Labels
bug 🪲 Something isn't working
Milestone

Comments

@bertellil-prom
Copy link

Describe the bug

When attempting to import an Azure Role Assignment using asoctl import azure-resource, the command results in a panic with the following error:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x30 pc=0x105b87a98]

Steps to Reproduce

  1. Run the following command (Azure resource-specific details redacted for privacy):
    asoctl import azure-resource /subscriptions/<subscription-id>/providers/Microsoft.Authorization/roleAssignments/<role-assignment-id> --verbose
  2. Observe the error logs, including the panic message.

Observed Behavior

The command fails and produces the following stack trace:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x30 pc=0x105b87a98]

goroutine 74 [running]:
github.com/Azure/azure-service-operator/v2/api/authorization/customizations.(*RoleAssignmentExtension).Import(0x1087d5ffe?, {0x10a50b1a0?, 0x140004c4d70?}, {0x10a4cc680, 0x14000c77800}, 0x0, 0x14000c01c08?)
	/workspace/v2/api/authorization/customizations/role_assignment_extensions.go:38 +0x88
github.com/Azure/azure-service-operator/v2/cmd/asoctl/pkg/importresources.(*importableARMResource).createImportFunction.func1({0x10a50b1a0?, 0x140004c4d70?}, {0x10a4cc680?, 0x14000c77800?}, 0x108faa825?)
	/workspace/v2/cmd/asoctl/pkg/importresources/importable_arm_resource.go:219 +0x54
github.com/Azure/azure-service-operator/v2/cmd/asoctl/pkg/importresources.(*importableARMResource).createImportFunction.(*importableARMResource).clearStatus.func3({0x10a50b1a0?, 0x140004c4d70?}, {0x10a4cc680, 0x14000c77800}, 0x1400010e240?)
	/workspace/v2/cmd/asoctl/pkg/importresources/importable_arm_resource.go:276 +0x40
github.com/Azure/azure-service-operator/v2/cmd/asoctl/pkg/importresources.(*importableARMResource).Import(0x14000a66d40, {0x10a50b1a0, 0x140004c4d70}, {{0x2?, 0x2?}, 0x1087b74a4?})
	/workspace/v2/cmd/asoctl/pkg/importresources/importable_arm_resource.go:114 +0xb8
github.com/Azure/azure-service-operator/v2/cmd/asoctl/pkg/importresources.(*ResourceImporter).importResource(0x1400008c900, {0x10a50b1a0, 0x140004c4d70}, {0x10a50db00, 0x14000a66d40}, {0x10a4f8038, 0x140005860f0})
	/workspace/v2/cmd/asoctl/pkg/importresources/resource_importer.go:277 +0x178
github.com/Azure/azure-service-operator/v2/cmd/asoctl/pkg/importresources.(*ResourceImporter).importWorker(0x1400008c900, {0x10a50b1a0, 0x140004c4d70}, 0x14000a62c40, 0x14000a62cb0, {0x10a4f8038, 0x140005860f0})
	/workspace/v2/cmd/asoctl/pkg/importresources/resource_importer.go:204 +0x184
created by github.com/Azure/azure-service-operator/v2/cmd/asoctl/pkg/importresources.(*ResourceImporter).Import in goroutine 1
	/workspace/v2/cmd/asoctl/pkg/importresources/resource_importer.go:96 +0x158

Expected Behavior

The resource import should complete successfully without any runtime errors.

Environment

  • ASO Version: v2.11.0
  • Command Used: asoctl import azure-resource
  • Resource Details: Azure Role Assignment (specific details redacted)
  • Azure Environment: Public Azure

Additional Information

  • The issue appears to be linked to the RoleAssignmentExtension implementation at /workspace/v2/api/authorization/customizations/role_assignment_extensions.go:38.
  • Similar issues may be occurring in the resource importer at /workspace/v2/cmd/asoctl/pkg/importresources.
@theunrepentantgeek
Copy link
Member

Looks like I assumed a RoleAssignment would never be directly imported, only encountered as a resource extension when importing another resource - this would explain why the code assumes the owner value supplied to Import() is never nil. Should be a straightforward fix - and I'll check other implementations of Import() as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working
Projects
Status: Ready for Release
Development

Successfully merging a pull request may close this issue.

2 participants