Closed mikelmao closed 3 weeks ago
The error "vars() argument must have __dict__ attribute" indicates that the oauth_provider
object does not have a __dict__
attribute, which is typically present in instances of classes that use the default __init__
method to store attributes.
In the Dify codebase, the oauth_provider
object is an instance of the NotionOAuth
class. This class should have attributes like client_id
, client_secret
, and redirect_uri
[1].
To resolve this issue, you can modify the NotionOAuth
class to ensure it has a __dict__
attribute. One way to do this is to define the __slots__
attribute in the class, which explicitly declares data members and prevents the creation of a __dict__
attribute. If __slots__
is used, you can remove it to allow the creation of a __dict__
attribute.
Here's an example of how you might modify the NotionOAuth
class:
class NotionOAuth:
def __init__(self, client_id, client_secret, redirect_uri):
self.client_id = client_id
self.client_secret = client_secret
self.redirect_uri = redirect_uri
# Add other necessary attributes here
If __slots__
is defined in the class, remove it:
class NotionOAuth:
__slots__ = ['client_id', 'client_secret', 'redirect_uri'] # Remove this line if it exists
def __init__(self, client_id, client_secret, redirect_uri):
self.client_id = client_id
self.client_secret = client_secret
self.redirect_uri = redirect_uri
# Add other necessary attributes here
After making this change, the vars(oauth_provider)
call should work as expected, allowing you to proceed with the Notion integration.
If the NotionOAuth
class is already defined without __slots__
and the issue persists, ensure that the oauth_provider
object is correctly instantiated and not None
or an unexpected type.
To continue talking to Dosu, mention @dosu.
As additional information @dosu it states in the docs that if you use internal as the notion integration type, it does not require the other fields other than the secret.
The error "vars() argument must have __dict__ attribute" occurs because the oauth_provider
object does not have a __dict__
attribute. This is typically present in instances of classes that use the default __init__
method to store attributes.
In the Dify codebase, the oauth_provider
object is an instance of the NotionOAuth
class. This class should have attributes like client_id
, client_secret
, and redirect_uri
[1].
Given that the NOTION_INTEGRATION_TYPE
is set to "internal" and only the NOTION_INTERNAL_SECRET
is required, ensure that the NotionOAuth
class is correctly instantiated and has the necessary attributes.
Here's an example of how you might modify the NotionOAuth
class to ensure it has a __dict__
attribute:
class NotionOAuth:
def __init__(self, client_id=None, client_secret=None, redirect_uri=None):
self.client_id = client_id
self.client_secret = client_secret
self.redirect_uri = redirect_uri
# Add other necessary attributes here
If __slots__
is defined in the class, remove it:
class NotionOAuth:
__slots__ = ['client_id', 'client_secret', 'redirect_uri'] # Remove this line if it exists
def __init__(self, client_id=None, client_secret=None, redirect_uri=None):
self.client_id = client_id
self.client_secret = client_secret
self.redirect_uri = redirect_uri
# Add other necessary attributes here
After making this change, the vars(oauth_provider)
call should work as expected, allowing you to proceed with the Notion integration.
Additionally, ensure that the oauth_provider
object is correctly instantiated and not None
or an unexpected type. This should resolve the issue and allow you to continue with the Notion integration.
To continue talking to Dosu, mention @dosu.
Line 39: oauth_provider = OAUTH_DATASOURCE_PROVIDERS.get(provider) Return Nonetype cause the Vars() cannot work properly
Self Checks
Dify version
0.6.13
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
Results in
Sentry shows the following lines of code:
Specifically erroring out on
✔️ Expected Behavior
Continuing with the ability to hook up a workspace
❌ Actual Behavior
Error: "vars() argument must have dict attribute"