Skip to content

fix(resolve): handle members with null email in resolve_user_async - #37

Open
eb-terry-tyz wants to merge 1 commit into
cpatrickalves:mainfrom
eb-terry-tyz:fix/null-email-assignee
Open

eb-terry-tyz wants to merge 1 commit into
cpatrickalves:mainfrom
eb-terry-tyz:fix/null-email-assignee

Conversation

@eb-terry-tyz

Copy link
Copy Markdown

Problem

planecli wi ls --assignee <name> fails on workspaces that contain members
provisioned via SSO. Plane returns those members with email: None (the key is
present, the value is null), and the async resolver does:

if m.get("email", "").lower() == query.lower():

The "" default only covers a missing key, so .lower() is called on None
and raises AttributeError. Because the loop iterates over all members before
the name-based fallback runs, a single such member breaks every name/UUID
lookup, not just lookups for that user. This made --assignee unusable for us
until we worked around it by listing all work items and filtering by user id.

Fix

Guard the value rather than the key, matching what the synchronous
resolve_user already does at line 224:

email = m.get("email")
if email and email.lower() == query.lower():
    return m

The email and guard (rather than (m.get("email") or "")) also prevents an
empty query from matching the first member that has no email.

Tests

Added TestResolveUserAsyncNullEmail in tests/test_resolve.py with three
cases against a member list containing email: None entries:

  • fuzzy display_name lookup still resolves the right member
  • case-insensitive exact email match still works
  • an empty query does not match a null-email member

Verification

Ran the same checks as CI (uv sync --locked && make check) on top of
ba300d4 / v0.6.0:

  • ruff check src/ tests/ — passed
  • ruff format --check src/ tests/ — 43 files already formatted
  • pytest tests/ — 245 passed

Also confirmed against a live Plane instance that
planecli wi ls -p SOLOCO --assignee 黄晨旭 now returns the expected 5 work
items, and that --assignee me and unknown-name handling are unchanged.

Plane returns `email: None` for SSO-provisioned members. `m.get("email", "")`
does not protect against this because the key exists with a null value, so
`.lower()` raised AttributeError and any `--assignee <name>` lookup failed as
soon as such a member was present in the workspace.

Guard the value itself (matching the existing sync `resolve_user` logic) and
skip empty emails so an empty query cannot accidentally match a member that
has no email. Adds regression tests for fuzzy name lookup, case-insensitive
exact email match, and the empty-query case.
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