Skip to content

Transactions.create(order_id=...) always raises TypeError #16

Description

@aaronelliotross

What's happening

Transactions.create() (actionkit/transactions.py:97):

order_uri = order_uri or Orders.get_resource_uri_from_id(order_id)

get_resource_uri_from_id is inherited from HttpMethods:

def get_resource_uri_from_id(self, resource_id):
    return self.connection.get_resource_uri_from_id(resource_id, self.resource_name)

It's an instance method. Calling it as Orders.get_resource_uri_from_id(order_id) — unbound, on the Orders class rather than an Orders instance — binds order_id to the method's self parameter and leaves the real resource_id parameter unfilled. This raises:

TypeError: get_resource_uri_from_id() missing 1 required positional argument: 'resource_id'

Impact

Transactions.create(order_id=..., ...) (i.e. any caller that supplies order_id instead of order_uri) is currently completely broken — it never reaches the network.

Contrast with the correct pattern elsewhere in the codebase, e.g. actionkit/orders.py:23:

resource_uri = self.get_resource_uri_from_id(resource_id)

Suggested fix

order_uri = order_uri or self.connection.get_resource_uri_from_id(order_id, "order")

or construct an Orders(self.connection) instance and call the bound method on it.

Test coverage

Pinned (not fixed) by tests/test_transactions.py::test_create_with_order_id_is_broken, which asserts the current TypeError. That test should be updated to assert success once this is fixed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions