You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Report helpful error message for missing "jwt" dependency #526
Is your feature request related to a problem? Please describe.
As is known from closed issue (#387) if you don't pip install "boxsdk[jwt]", and use the JWT authorization, you get a somewhat confusing message:
File "/Users/first.last/workspace/repo_name/box/../lib/box.py", line 70, in get_jwt_client
auth = boxsdk.JWTAuth.from_settings_file(load_config(self.app_name))
AttributeError: 'NoneType' object has no attribute 'from_settings_file'
Describe the solution you'd like
Return an error message instead that at least suggests "Did you try pip install boxsdk[jwt]?" when JWTAuth isn't going to work.
@supermitch We are currently prioritizing bugs over enhancements in all our SDKs, so it may take a while for us to get to some of these. If are interested in submitting PRs for the enhancements, we would love to take a look!
I'm having a similar issue when using the library in AWS Lambda, even though I installed the JWT extra (I downloaded the ZIP from Lambda and run it locally to double check):
My suspicion is that there's actually a different ImportError being raised, but it's not getting logged anywhere:
$ cat boxsdk/auth/__init__.py
# coding: utf-8from __future__ importunicode_literalsfrom .cooperatively_managed_oauth2importCooperativelyManagedOAuth2from .developer_token_authimportDeveloperTokenAuthtry:
from .jwt_authimportJWTAuthexceptImportError:
JWTAuth=None# If extras[jwt] are not installed, JWTAuth won't be available.
Update: I was able to log the error and my suspicion was confirmed:
Traceback (most recent call last):
--
File "/var/task/boxsdk/auth/__init__.py", line 8, in<module>
from .jwt_auth import JWTAuth
File "/var/task/boxsdk/auth/jwt_auth.py", line 12, in<module>
from cryptography.hazmat.primitives import serialization
File "/var/task/cryptography/hazmat/primitives/serialization/__init__.py", line 15, in<module>
from cryptography.hazmat.primitives.serialization.base import (
File "/var/task/cryptography/hazmat/primitives/serialization/base.py", line 11, in<module>
from cryptography.hazmat.primitives.asymmetric.types import (
File "/var/task/cryptography/hazmat/primitives/asymmetric/types.py", line 7, in<module>
from cryptography.hazmat.primitives.asymmetric import (
File "/var/task/cryptography/hazmat/primitives/asymmetric/dsa.py", line 12, in<module>
from cryptography.hazmat.primitives.asymmetric import (
File "/var/task/cryptography/hazmat/primitives/asymmetric/utils.py", line 6, in<module>
from cryptography.hazmat.bindings._rust import asn1
ImportError: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by /var/task/cryptography/hazmat/bindings/_rust.abi3.so)
Would be nice to log these errors instead of swallowing them:
importlogging
...
try:
from .jwt_authimportJWTAuthexceptImportError:
logging.exception("An import error occurred") # Could be a warning as wellJWTAuth=None# If extras[jwt] are not installed, JWTAuth won't be available.
...
It could also capture the error and ignore it if the cause is that the JWTAuth class is actually not found, while raising the error otherwise. I'm not entirely sure if it would raise an error unnecessarily in scenarios in which the user doesn't care about one of the extra modules.
I've just been hit with the same issue as @federicojasson - issue with cryptography bindings when deployed on AWS Lambda being swallowed and raised as AttributeError: 'NoneType' object has no attribute 'from_settings_dictionary'.
Interestingly, the original error does get surfaced correctly when I import directly:
I have tried installing only Boxsdk (without boxsdk[jwt]) and both of them at once as well. But i still see the issue
[ERROR] AttributeError: 'NoneType' object has no attribute 'from_settings_dictionary'
Traceback (most recent call last):
File "/var/task/lambda_function.py", line 70, in lambda_handler
auth = JWTAuth.from_settings_dictionary(json.loads(secret))
Runtime : Python 3.11
I've read in some articles that it's important where we build the package. So i've tried building it both it local pc and in the cloudshell as well. Yet the issue persists
Activity
sujaygarlanka commentedon Jul 17, 2020
@supermitch Thank you for the feedback! We will take a look at this.
sujaygarlanka commentedon Sep 10, 2020
@supermitch We are currently prioritizing bugs over enhancements in all our SDKs, so it may take a while for us to get to some of these. If are interested in submitting PRs for the enhancements, we would love to take a look!
federicojasson commentedon Oct 14, 2021
I'm having a similar issue when using the library in AWS Lambda, even though I installed the JWT extra (I downloaded the ZIP from Lambda and run it locally to double check):
$ treeMy suspicion is that there's actually a different
ImportErrorbeing raised, but it's not getting logged anywhere:$ cat boxsdk/auth/__init__.pyUpdate: I was able to log the error and my suspicion was confirmed:
Would be nice to log these errors instead of swallowing them:
It could also capture the error and ignore it if the cause is that the JWTAuth class is actually not found, while raising the error otherwise. I'm not entirely sure if it would raise an error unnecessarily in scenarios in which the user doesn't care about one of the extra modules.
regoawt commentedon Jul 3, 2023
I've just been hit with the same issue as @federicojasson - issue with
cryptographybindings when deployed on AWS Lambda being swallowed and raised asAttributeError: 'NoneType' object has no attribute 'from_settings_dictionary'.Interestingly, the original error does get surfaced correctly when I import directly:
rather than
bvrs-atri commentedon May 21, 2025
Hi @regoawt, I'm facing the same issue when trying to use Boxsdk as a layer for Lambda Function.
This is what i followed to create layer. AWS Docs
I have tried installing only Boxsdk (without boxsdk[jwt]) and both of them at once as well. But i still see the issue
Runtime : Python 3.11
I've read in some articles that it's important where we build the package. So i've tried building it both it local pc and in the cloudshell as well. Yet the issue persists
Anyway to solve this ?