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

Azure servicebus transport has hidden dependency on azure-identity package #2045

Closed
Korijn opened this issue Jun 27, 2024 · 10 comments · Fixed by #2053
Closed

Azure servicebus transport has hidden dependency on azure-identity package #2045

Korijn opened this issue Jun 27, 2024 · 10 comments · Fixed by #2053

Comments

@Korijn
Copy link

Korijn commented Jun 27, 2024

The azure-servicebus transport depends on azure-identity package, even though it is not listed:

azure-servicebus>=7.10.0

It looks like the code intends for it to be optional:

try:
from azure.identity import (DefaultAzureCredential,
ManagedIdentityCredential)
except ImportError:
DefaultAzureCredential = None
ManagedIdentityCredential = None

But of course it crashes here when (effectively) calling isinstance(..., None)

def _try_parse_connection_string(self) -> None:
self._namespace, self._credential = Transport.parse_uri(
self.conninfo.hostname)
if (isinstance(self._credential, DefaultAzureCredential) or
isinstance(self._credential, ManagedIdentityCredential)):
return None

File "/app/.venv/lib/python3.9/site-packages/kombu/transport/azureservicebus.py", line 144, in _try_parse_connection_string
    if (isinstance(self._credential, DefaultAzureCredential) or
TypeError: isinstance() arg 2 must be a type or tuple of types

This problem was introduced in #1641 #1801

@Nusnus
Copy link
Member

Nusnus commented Jun 30, 2024

This problem was introduced in #1641

@jasonwbarnett hey friend - can you check this out please?

@jesusgarmanz
Copy link

Hi! Seems like this is the same issue I found on #1947

@Nusnus
Copy link
Member

Nusnus commented Jul 8, 2024

@Korijn @jesusgarmanz any of you want to offer a PR to fix this issue? 🙂

@jasonwbarnett
Copy link
Contributor

@Nusnus I got this.

@jasonwbarnett
Copy link
Contributor

jasonwbarnett commented Jul 9, 2024

This break was introduced in #1801, not #1641

You know what. The original intent was to make this optional. In other words, don't force azure-identity down people's throats. They should only install it, optionally, if they require the use of either of the new features introduced in #1641

That said, I could update the code to throw an exception detailing what steps are necessary if they wish to use it and update the docs. I don't think adding a forced requirement makes sense here.

Thoughts?

@Korijn
Copy link
Author

Korijn commented Jul 9, 2024

Yeah, that's what I said:

It looks like the code intends for it to be optional:

But it's implemented in a way that it isn't actually optional.

@jasonwbarnett
Copy link
Contributor

jasonwbarnett commented Jul 9, 2024

@Korijn I would like input from @marnikow. He introduced the isinstance() check which introduced this bug. I don't know what the isinstance() check does here. I no longer have the job where I was using this code in production for over a year (code without @marnikow fixes). I need input from him so I can get more context.

@jasonwbarnett
Copy link
Contributor

Actually, I just hacked this into place. This should work now.

@jasonwbarnett
Copy link
Contributor

@Korijn can you update the issue description so that it accurately references #1801 as the PR which introduced the bug you've reported?

@Korijn
Copy link
Author

Korijn commented Jul 9, 2024

@Korijn can you update the issue description so that it accurately references #1801 as the PR which introduced the bug you've reported?

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants