Closed wilmardo closed 3 years ago
Hi @wilmardo! 👋🏼
Thanks for raising this issue. Would you be so kind as to share the code you used to reproduce this exception so we can do some further debugging?
Hi @angelomelonas thanks for checking in!
I will try to reproduce this on the latest SDK release but my guess it that this issue has been fixed by one of the releases after 1.10.6
.
Hi @wilmardo,
Thanks for the response. If the issue has been fixed with the newer releases, would you mind closing the issue? 😄
@angelomelonas I would love to close the issue but not before testing :)
Just tested this again and the bug is still there so it would be nice if it could be reopened.
This is the relevant code in split.py
where end_date is a DateTime
object:
# split.py
payment_events: List[endpoint.Event] = utils.get_events(
monetary_account_id=monetary_account.id_,
types=["Payment"],
end_date=stop)
The function called in utils.py
look like this and breaks on Event.list
# utils.py
def get_events(monetary_account_id: int, types: Optional[List[str]], includes: Optional[List[str]],
excludes: Optional[List[str]], end_date: Optional[datetime.datetime]) -> List[Event]:
"""Get events for a certain account
Args:
monetary_account_id (int): Monetary account id
types (List[str]): API types to filter from events
includes (List[str]): IBAN number to include
excludes (List[str]): IBAN numbers to exclude
end_date (datetime.datetime): Date to stop looking for events
Returns:
List[Event]: List of events
"""
events: List[Event] = []
result: List[Event] = []
try:
# Loop until we raise or return
while True:
# Check if first iteration (unsplit_payments empty)
if not events:
# We will loop over the payments in batches of 200
pagination = Pagination()
pagination.count = 200
params = pagination.url_params_count_only
else:
# TODO: Fix this, this does not seem to work
# BunqException('Could not generate previous page URL params: there is no previous page.',)
# When there is already a paged request, you can get the next page from it, no need to create it ourselfs:
try:
params = pagination.url_params_previous_page
except BunqException:
# Break the loop, there is no more to process
raise StopIteration
# Add parameters to only list for current monetary_account_id
params['monetary_account_id'] = monetary_account_id
params['display_user_event'] = 'false'
# Get events
events = Event.list(
params=params,
).value
except StopIteration: return result
Full traceback:
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/wilmardo/.vscode-insiders/extensions/ms-python.python-2020.8.106424/pythonFiles/lib/python/debugpy/__main__.py", line 45, in <module>
cli.main()
File "/home/wilmardo/.vscode-insiders/extensions/ms-python.python-2020.8.106424/pythonFiles/lib/python/debugpy/../debugpy/server/cli.py", line 430, in main
run()
File "/home/wilmardo/.vscode-insiders/extensions/ms-python.python-2020.8.106424/pythonFiles/lib/python/debugpy/../debugpy/server/cli.py", line 267, in run_file
runpy.run_path(options.target, run_name=compat.force_str("__main__"))
File "/usr/lib/python3.8/runpy.py", line 263, in run_path
return _run_module_code(code, init_globals, run_name,
File "/usr/lib/python3.8/runpy.py", line 96, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/usr/lib/python3.8/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/wilmardo/Development/buaut/venv/bin/buaut", line 10, in <module>
sys.exit(main())
File "/home/wilmardo/Development/buaut/venv/lib/python3.8/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/home/wilmardo/Development/buaut/venv/lib/python3.8/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/home/wilmardo/Development/buaut/venv/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/wilmardo/Development/buaut/venv/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/wilmardo/Development/buaut/venv/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/wilmardo/Development/buaut/venv/lib/python3.8/site-packages/click/decorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/wilmardo/Development/buaut/buaut/command/split.py", line 63, in split
# to get a correct reference
File "/home/wilmardo/Development/buaut/buaut/utils.py", line 99, in get_events
events = Event.list(
File "/home/wilmardo/Development/buaut/venv/lib/python3.8/site-packages/bunq/sdk/model/generated/endpoint.py", line 10672, in list
cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET)
File "/home/wilmardo/Development/buaut/venv/lib/python3.8/site-packages/bunq/sdk/model/core/bunq_model.py", line 104, in _from_json_list
item_deserialized = converter.deserialize(cls, item_unwrapped)
File "/home/wilmardo/Development/buaut/venv/lib/python3.8/site-packages/bunq/sdk/json/converter.py", line 444, in deserialize
return JsonAdapter.deserialize(cls, obj_raw)
File "/home/wilmardo/Development/buaut/venv/lib/python3.8/site-packages/bunq/sdk/json/converter.py", line 102, in deserialize
return cls._deserialize_default(cls_target, obj_raw)
File "/home/wilmardo/Development/buaut/venv/lib/python3.8/site-packages/bunq/sdk/json/converter.py", line 117, in _deserialize_default
return cls._deserialize_dict(cls_target, obj_raw)
File "/home/wilmardo/Development/buaut/venv/lib/python3.8/site-packages/bunq/sdk/json/converter.py", line 147, in _deserialize_dict
dict_deserialized = cls._deserialize_dict_attributes(cls_target, dict_)
File "/home/wilmardo/Development/buaut/venv/lib/python3.8/site-packages/bunq/sdk/json/converter.py", line 163, in _deserialize_dict_attributes
dict_deserialized[value_specs.name] = cls._deserialize_value(value_specs.types, dict_[key])
File "/home/wilmardo/Development/buaut/venv/lib/python3.8/site-packages/bunq/sdk/json/converter.py", line 270, in _deserialize_value
return cls.deserialize(types.main, value)
File "/home/wilmardo/Development/buaut/venv/lib/python3.8/site-packages/bunq/sdk/json/converter.py", line 104, in deserialize
return deserializer.deserialize(cls_target, obj_raw)
File "/home/wilmardo/Development/buaut/venv/lib/python3.8/site-packages/bunq/sdk/json/anchor_object_adapter.py", line 29, in deserialize
model_ = super()._deserialize_default(cls_target, obj_raw)
File "/home/wilmardo/Development/buaut/venv/lib/python3.8/site-packages/bunq/sdk/json/converter.py", line 117, in _deserialize_default
return cls._deserialize_dict(cls_target, obj_raw)
File "/home/wilmardo/Development/buaut/venv/lib/python3.8/site-packages/bunq/sdk/json/converter.py", line 147, in _deserialize_dict
dict_deserialized = cls._deserialize_dict_attributes(cls_target, dict_)
File "/home/wilmardo/Development/buaut/venv/lib/python3.8/site-packages/bunq/sdk/json/converter.py", line 163, in _deserialize_dict_attributes
dict_deserialized[value_specs.name] = cls._deserialize_value(value_specs.types, dict_[key])
File "/home/wilmardo/Development/buaut/venv/lib/python3.8/site-packages/bunq/sdk/json/converter.py", line 270, in _deserialize_value
return cls.deserialize(types.main, value)
File "/home/wilmardo/Development/buaut/venv/lib/python3.8/site-packages/bunq/sdk/json/anchor_object_adapter.py", line 29, in deserialize
model_ = super()._deserialize_default(cls_target, obj_raw)
File "/home/wilmardo/Development/buaut/venv/lib/python3.8/site-packages/bunq/sdk/json/converter.py", line 117, in _deserialize_default
return cls._deserialize_dict(cls_target, obj_raw)
File "/home/wilmardo/Development/buaut/venv/lib/python3.8/site-packages/bunq/sdk/json/converter.py", line 147, in _deserialize_dict
dict_deserialized = cls._deserialize_dict_attributes(cls_target, dict_)
File "/home/wilmardo/Development/buaut/venv/lib/python3.8/site-packages/bunq/sdk/json/converter.py", line 163, in _deserialize_dict_attributes
dict_deserialized[value_specs.name] = cls._deserialize_value(value_specs.types, dict_[key])
File "/home/wilmardo/Development/buaut/venv/lib/python3.8/site-packages/bunq/sdk/json/converter.py", line 270, in _deserialize_value
return cls.deserialize(types.main, value)
File "/home/wilmardo/Development/buaut/venv/lib/python3.8/site-packages/bunq/sdk/json/anchor_object_adapter.py", line 33, in deserialize
object_class = cls._get_object_class(field)
File "/home/wilmardo/Development/buaut/venv/lib/python3.8/site-packages/bunq/sdk/json/anchor_object_adapter.py", line 64, in _get_object_class
raise BunqException(cls.__ERROR_MODEL_NOT_FOUND.format(class_name))
bunq.sdk.exception.bunq_exception.BunqException: BillingInvoice is not in endpoint nor object
This time tested against production :)
I am currently refactoring back to the Payment endpoint which has no issue then I can get past the problematic payment without an issue :+1:
Steps to reproduce:
What should happen:
What happens:
Traceback
SDK version and environment
Extra info:
This error is expected since there is no generated BillingInvoice in the generated classes nor endpoint.