Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Blank error returned when using a key without Manage permission with SubscriptionManager.Get #229

Closed
MattJeanes opened this issue May 20, 2021 · 5 comments · Fixed by #258

Comments

@MattJeanes
Copy link

Azure Service Bus Go version: v0.10.12 (latest at time of writing)
Go version: go version go1.15.6 linux/amd64

As in the title, currently a blank error is returned when the call to SubscriptionManager.Get internally receives a 401 code (401 SubCode=40104: Invalid authorization token audience)

In my scenario, this was caused by using a service bus connection string without Manage permissions, only Send and Listen. I've had to debug right into the code in this package to have any idea of what was going on, and has caused difficult to diagnose downstream issues such as kedacore/keda#1499.

It would be fantastic if we could return a useful error here that could help users resolve the issue without having to resort to debugging in to see what's going on.

Minimal repro:

package main

import (
	"context"
	"fmt"
	servicebus "github.com/Azure/azure-service-bus-go"
)

func main() {
	var namespace *servicebus.Namespace
	var err error
	var ctx = context.TODO()

	namespace, err = servicebus.NewNamespace(servicebus.NamespaceWithConnectionString("<connection string here>"))
	if err != nil {
		fmt.Printf("servicebus.NewNamespace: %s", err.Error())
		return
	}

	subscriptionManager, err := namespace.NewSubscriptionManager("<topic name here>")
	if err != nil {
		fmt.Printf("namespace.NewSubscriptionManager: %s", err.Error())
		return
	}

	subscriptionEntity, err := subscriptionManager.Get(ctx, "<subscription name here>")
	if err != nil {
		fmt.Printf("subscriptionManager.Get: %s", err.Error())
		return
	}

	fmt.Printf("getSubscriptionEntityFromNamespace: active message count %d", *subscriptionEntity.CountDetails.ActiveMessageCount)
}
@tomkerkhove
Copy link
Member

Any news on this?

@MattJeanes
Copy link
Author

@tomkerkhove looks like this is being handled as part of Azure/azure-sdk-for-go#15090 which has seen some very recent activity so hopefully still on the radar!

@richardpark-msft
Copy link
Member

I promise this is a coincidence, but I was actually just looking at this.

@tomkerkhove, I've got a PR to fix this, needs to get reviewed and hopefully released next week.
@MattJeanes - you're 100% right that we have a new library being developed.

We just released beta 1 here: https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/messaging/azservicebus/

If you're interested there's a migration guide here as well: https://github.com/Azure/azure-sdk-for-go/blob/main/sdk/messaging/azservicebus/migrationguide.md.

We're still missing some functionality, but it's getting added fast :)

richardpark-msft added a commit that referenced this issue Oct 18, 2021
…nagers" (#258)

The various manager APIs all had their own error handling code, which would result in them occasionally obscuring the actual HTTP response error. 

We're now respecting the HTTP status codes and anything >= 400 causes us to fail with an actual error with text, rather than an empty error.

Fixes #229
@richardpark-msft
Copy link
Member

@MattJeanes - this fix has now been released in https://github.com/Azure/azure-service-bus-go/releases/tag/v0.11.3

@MattJeanes
Copy link
Author

Thank you @richardpark-msft - great work!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants