Skip to content

fix(ownership): owner IDs returned as int, crashes avatar trim() #110594

@sentry-junior

Description

@sentry-junior

Summary

The ownership rules widget crashes with TypeError: e?.trim is not a function when rendering team avatars. The backend serializes owner id as a Python int; the frontend Actor type expects id: string. When the team is missing from TeamStore, the numeric ID flows into getInitials() as name, and .trim() throws on a number.

Root Cause

add_owner_ids_to_schema() in grammar.py stores the raw DB integer:

# before
rule_owner["id"] = owners_id[rule_owner["identifier"]]  # int

So the GET /api/0/{org}/{project}/ownership/ response looks like:

{ "type": "team", "name": "#my-team", "id": 2251960 }

Downstream chain:

  1. TeamStore.getById(owners[0].id) — string/number mismatch, returns null
  2. Fallback renders <Avatar name={teamId}> where teamId is the number 2251960
  3. getInitials(name) calls name.trim() → crash

Confirmed in debugger: name = 2251960 (number), sanitizedName unavailable.

Versions Affected

Confirmed in demo org. Affects any project with ownership rules referencing teams not fully loaded in TeamStore.

Related

Action taken on behalf of David Cramer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions