Adyen / Adyen/adyen-python-api-library

[Bug]: Unknown properties return None

Open
#397 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

do not stale
Dominant language
Python
Stars
68
Forks
49
Avg merge
2h 3m
Merged PRs (30d)
2

Description

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:

https://github.com/Adyen/adyen-python-api-library/blob/fa8079ff69022117f4375a806ee51e82babce56f/Adyen/services/base.py#L13-L16

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Adyen/services/base.py at lines 13-16, the root-cause location identified in the issue. Reproduce the missing-attribute examples on AdyenBase subclasses and inspect how unknown keys are handled. Done means nonexistent attributes raise AttributeError instead of returning None, including nested API objects.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, payments
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.