Skip to content

Follow / resolve by username (get_user_by_username, follow_by_username, unfollow_by_username)#116

Open
arch-colony wants to merge 1 commit into
mainfrom
feat/follow-by-username
Open

Follow / resolve by username (get_user_by_username, follow_by_username, unfollow_by_username)#116
arch-colony wants to merge 1 commit into
mainfrom
feat/follow-by-username

Conversation

@arch-colony

Copy link
Copy Markdown
Collaborator

Reported by @reticuli: the messaging methods key on username, but the user-id methods (follow, get_user, block_user, report_user, get_followers) key on UUID — and there was no bridge. An agent holding only a handle (e.g. from a mention) had to fish a UUID out of a post's author object, or had no path to the id at all. The asymmetry is surprising precisely because the messaging surface already proves the server can resolve handles.

What's added

Three methods on the sync client, the async client, and the testing mock:

client.get_user_by_username("reticuli")   # -> profile incl. id  (the username->id bridge)
client.follow_by_username("reticuli")      # same as follow(), by handle
client.unfollow_by_username("reticuli")    # same as unfollow(), by handle

Why separate methods, not one that accepts either

A username can be shaped like a UUID (the handle charset is hex + hyphens), so a single method that sniffed "is this a UUID or a handle?" could be steered to the wrong subject by an attacker registering a UUID-shaped handle. Keeping the by-id and by-username families distinct means the caller declares intent — no shape-guessing. (Server-side, THECOLONYC-562 also caps usernames below a UUID's length so the shapes can't collide at all, and adds the endpoints these call.)

⚠️ Do not release yet

These call GET/POST/DELETE /api/v1/users/by-username/{username}, which are on the platform master but not yet deployed. Releasing the SDK before the server endpoints are live would ship methods that 404. No version bump in this PR — hold for merge/release until the server side is in prod.

Verification

Sync + async + mock at parity. Full suite 1159 passed; ruff check, ruff format --check, and mypy all clean. Run in a python:3.12 container.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Pxqw6ZyFv5f4rt5HFwtafs

Reported by @reticuli: the messaging methods key on username, the user-id
methods (follow, get_user, block_user, report_user, get_followers) key on
UUID, and there was NO bridge — so an agent holding only a handle (from a
mention, say) had to fish a UUID out of a post's author object, or had no
path to the id at all. The asymmetry is surprising precisely because the
messaging surface already proves the server can resolve handles.

Adds three methods to the sync client, the async client and the testing mock:

  get_user_by_username(username)  -> profile incl. id  (the username->id bridge)
  follow_by_username(username)    -> same as follow(), addressed by handle
  unfollow_by_username(username)  -> same as unfollow(), addressed by handle

SEPARATE methods, NOT an overload that guesses UUID-vs-handle. A username can
be shaped like a UUID, so a method that sniffed its argument could be steered
to the wrong subject; keeping the two families distinct means the caller
declares intent. (Server-side, THECOLONYC-562 also caps usernames below a
UUID's length so the shapes cannot collide at all, and adds the endpoints
these call.)

NO version bump — per instruction. The methods depend on the server endpoints
`GET/POST/DELETE /api/v1/users/by-username/{username}`, which are on the
platform master but NOT yet deployed, so this must NOT be released until they
are live in prod. Opening as a PR to hold until then.

Sync + async + mock at parity. Full suite 1159 passed; ruff, ruff format, mypy
all clean.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01Pxqw6ZyFv5f4rt5HFwtafs
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.

1 participant