Skip to content

feat(smart-assignment): Fuzzy-match candidates - #124232

Merged
hobzcalvin merged 2 commits into
masterfrom
sa-fuzzy-match
Sep 14, 2026
Merged

hobzcalvin merged 2 commits into
masterfrom
sa-fuzzy-match

Conversation

@hobzcalvin

Copy link
Copy Markdown
Contributor

There have been clear instances, even with Sentry employees, where hidden GitHub emails prevent us from resolving the actual person responsible for an issue. Here we attempt to fuzzy-match names (newly emitted by the Smart Assignment agent in https://github.com/getsentry/seer/pull/8185) and email addresses to users in the database, with some hopefully-comprehensive regexes that match across email domains, added/missing middle names/initials, various separators, etc.

If even 2 users match the input, we give up fuzzy matching. Better to not match than to match the OTHER John Smith.

For now, we log the results and don't actually use the fuzzy match. I want to monitor the results carefully and only enable if they look solid.

@hobzcalvin
hobzcalvin requested review from a team as code owners September 11, 2026 23:57
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Sep 11, 2026
Comment on lines +472 to +473
if len(parts) == 1:
return re.escape(parts[0])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The fuzzy user matching logic creates an overly strict regex for single-word names, causing it to fail to match users with multi-word names (e.g., "Dana" won't match "Dana Smith").
Severity: MEDIUM

Suggested Fix

Modify the _name_pattern function to generate a more flexible regex for single-word names. Instead of returning a pattern for an exact match, it should return a pattern that allows for additional words, similar to how multi-word names are handled. For example, for the name "Dana", the pattern should match names that start with "Dana", such as "Dana Smith".

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: src/sentry/users/services/user/impl.py#L472-L473

Potential issue: The `_name_pattern()` function generates an overly restrictive regular
expression for single-word names. When provided with a single-word name like "Dana", it
creates the pattern `^Dana$`, which requires an exact match. This prevents matching
users with multi-word names like "Dana Smith". The issue manifests when fuzzy matching
is performed with a single-word name and an email that does not otherwise match the
target user. This leads to a failure in finding a valid user, even when a reasonable
match exists in the organization.

Did we get this right? 👍 / 👎 to inform future reviews.

@hobzcalvin
hobzcalvin enabled auto-merge (squash) September 14, 2026 18:50
@hobzcalvin
hobzcalvin merged commit e94252a into master Sep 14, 2026
88 checks passed
@hobzcalvin
hobzcalvin deleted the sa-fuzzy-match branch September 14, 2026 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants