Skip to content

Bug: _dispatch_request unknown-method fallback returns str, raises TypeError #151

Description

@martinkersner

Summary

API._dispatch_request returns the string "GET" as its fallback instead of a callable, so an unknown HTTP method raises TypeError (str is not callable) rather than dispatching or failing cleanly.

Location

datamaxi/api.py:188-194

def _dispatch_request(self, http_method):
    return {
        "GET": self.session.get,
        "DELETE": self.session.delete,
        "PUT": self.session.put,
        "POST": self.session.post,
    }.get(http_method, "GET")   # <-- fallback is the literal string "GET"

send_request then does self._dispatch_request(http_method)(**params). For any method not in the dict the result is "GET"(**params)TypeError: 'str' object is not callable.

Impact

Latent. Currently harmless only because methods come from the spec-driven registry, but it's a bug waiting for the first unexpected method and the error is misleading.

Fix

Fall back to self.session.get (the intended default), or raise a clear ValueError(f"unsupported HTTP method: {http_method}").


Surfaced during a pythonic-idiom review of the SDK.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingclaude-foundSurfaced by Claude

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions