Skip to content

user_subscriptions_create always fails because the server expects a dict keyed by HumanUser id #463

Open

Description

@VFXMystic

Hi folks!

With shotgun_api3 3.10.5 and current master, user_subscriptions_create(users) sends {"users": users}, and the server rejects every call with Fault: Uncaught exception! Invalid humanUserId users.

This happens even when re-sending a user's current subscription unchanged, as
user_subscriptions_read() reports it, with a script key or with an admin user login.

Server 8.91.0, Python 3.13.

Request shapes tried, each re-sending an unchanged entry (the first through
user_subscriptions_create(), the others through _call_rpc("user_subscriptions_create", ...)):

  • {"users": [{"humanUserId": N, "subscription": S}]} (current): Uncaught exception! Invalid humanUserId users
  • [{"humanUserId": N, "subscription": S}]: Uncaught exception! no implicit conversion of Array into Hash
  • {"N": S}, the shape user_subscriptions_read() returns: accepted; the response is {"N": None}

Suggested fix, which keeps the documented signature:

params = {str(user["humanUserId"]): user["subscription"] for user in users}
response = self._call_rpc("user_subscriptions_create", params)

Alternatively, the method could take the dict user_subscriptions_read() returns, so the two are symmetric.

Also:

  • The return check response.get("status") == "success" would be False even for the accepted call: its response has no status key. _call_rpc() already raises on errors. We could not tell what the per-user None values mean without changing a real assignment.
  • user_subscriptions_read is documented as returning a list, but it returns a dict keyed by user id.
  • SG-33870 Add methods for the user_subscriptions API end points #315, which added these methods, has no tests. A unit test asserting the request payload would have caught this.

Proposed PR: #464

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions