Skip to content

[Bug]: Unknown properties return None #397

@luhn

Description

@luhn

Description

Accessing a non-existent property on an API returns None instead of raising an AttributeError

Steps to reproduce

Attempt to access any non-existent attribute on any subclass of AdyenBase

>>> from Adyen import Adyen
>>> api = Adyen(xapikey='token', platform='test')
>>> print(api.foobar)
None
>>> print(api.payment.payments_api.foobar)
None
>>> api.payment.payments_api.fizz()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not callable

Actual behavior

Attempting to access non-existent attribute returns None. Attempting to call a non-existent method throws a "NoneType object is not callable" error.

Expected behavior

Should return an AttributeError.

Code snippet or screenshots (if applicable)

Root cause is here:

def __getattr__(self, attr):
client_attr = ["username", "password", "platform"]
if attr in client_attr:
return self.client[attr]

If key doesn't exist in self.client, the method exits with no return statement, which is the same as returning None. This means any attribute that's requested defaults to None. It should instead raise AttributeError

Adyen Python API Library version

14.0.0

Python Language version

Python 3.10

Operating System

macOS

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions