Skip to content

Fix user_subscriptions_create rejected by the server - #464

Open
VFXMystic wants to merge 1 commit into
shotgunsoftware:masterfrom
VFXMystic:fix-user-subscriptions-create
Open

VFXMystic wants to merge 1 commit into
shotgunsoftware:masterfrom
VFXMystic:fix-user-subscriptions-create

Conversation

@VFXMystic

Copy link
Copy Markdown

Fixes #463.

The server wants subscriptions as a dict keyed by HumanUser id, which is exactly what user_subscriptions_read hands back. user_subscriptions_create was sending {"users": [...]} instead, so every call failed with Invalid humanUserId users. It now builds the keyed dict from the same list argument as before, so the signature doesn't change.

The old return check (response.get("status") == "success") could never pass: the server doesn't send a status key, and _call_rpc already raises on errors. It now returns True when the server answers. I don't know what the per-user None values in the response mean, so I didn't try to interpret them.

While I was in there, I fixed the user_subscriptions_read docstring and return type. It returns a dict keyed by user id, not a list.

One thing to flag: user_subscriptions_create used to raise on every call, and now it actually assigns subscriptions.

Testing

  • New mocked tests in tests/test_client.py cover the request each method sends, and what user_subscriptions_create returns. These methods had no tests before.
  • tests/test_client.py passes on Python 3.9 and 3.13. (test_transform_data needs TZ=UTC on a machine outside UTC, with or without this change.)
  • pre-commit run --all-files passes, and flake8 has nothing new to say.
  • On a live site (server 8.91.0), re-sending a user's current subscription through the patched method returned True, and user_subscriptions_read was unchanged afterwards.

The server wants subscriptions keyed by HumanUser id (the shape
user_subscriptions_read returns), but the method sent {"users": [...]},
so every call failed. Fixes shotgunsoftware#463.

Also corrects the user_subscriptions_read docstring, and adds tests for
both methods.
@VFXMystic

Copy link
Copy Markdown
Author

re the red checks: they're the fork-secrets thing, not this change. Every test job fails with base_url must use http or https got '$(ci_site)', because the pipeline doesn't get the site variables on PRs from forks. That also takes out the mocked tests in test_client.py, since SG_SERVER_URL overrides the test config. On master with SG_SERVER_URL='$(ci_site)', test_client.py fails all 31 tests. On this branch with it unset, all 34 pass, including the 3 new ones. Style, typing and docs are green.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant