Skip to content

Conversation

@scttcper
Copy link
Member

@scttcper scttcper commented Oct 24, 2025

We allowed people to create projects with case insensitive slugs a while ago, its tricky to update them to not be case sensitive.

Adds a fallback lookup to case insensitive project slug. Fixes an issue where the errors dataset could not query by issue short id when the project contained uppercase letters. issue:PROJECTSLUG-E123

Redash query with number of project slugs that contain case insensitive characters
Redash query of projects with insensitive characters with recent issues

We allowed people to create projects with case insensitive slugs a while ago, its tricky to update them to not be case sensitive.

Adds a fallback lookup to case insensitive project slug
@scttcper scttcper requested review from a team and wedamija October 24, 2025 20:04
@scttcper scttcper requested review from a team as code owners October 24, 2025 20:04
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 24, 2025
Q(project__slug__iexact=slug, short_id__in=short_ids)
for slug, short_ids in project_short_id_lookup.items()
],
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: Unused Variable Causes Redundant Database Queries

The missing_short_ids variable is computed but not used when constructing the fallback query. This causes the case-insensitive lookup to re-query for short IDs that were already found in the initial exact-match query, leading to inefficient database operations.

Fix in Cursor Fix in Web

Copy link
Member Author

Choose a reason for hiding this comment

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

twist my arm

Copy link
Contributor

@cvxluo cvxluo left a comment

Choose a reason for hiding this comment

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

since this is on a pretty important path, should we hide this behind a flag as well?

Comment on lines 379 to 381
for sid in short_ids:
if sid.short_id in missing_short_ids:
missing_by_slug[sid.project_slug].append(sid.short_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

i think you hold all the missing short ids already in missing_short_ids?

Suggested change
for sid in short_ids:
if sid.short_id in missing_short_ids:
missing_by_slug[sid.project_slug].append(sid.short_id)
for missing_short_id in missing_short_ids
missing_by_slug[short_id.project_slug].append(short_id.short_id)

Comment on lines 403 to 405
existing_ids = {g.id for g in groups}
groups.extend(g for g in fallback_groups if g.id not in existing_ids)
group_lookup = {group.short_id for group in groups}
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't there guaranteed no overlap between fallback_groups and groups? do we need the additional check?

Suggested change
existing_ids = {g.id for g in groups}
groups.extend(g for g in fallback_groups if g.id not in existing_ids)
group_lookup = {group.short_id for group in groups}
groups.extend(g for g in fallback_groups)
group_lookup = {group.short_id for group in groups}

@codecov
Copy link

codecov bot commented Oct 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff            @@
##           master   #102103   +/-   ##
========================================
  Coverage   80.95%    80.96%           
========================================
  Files        8743      8742    -1     
  Lines      389054    389022   -32     
  Branches    24693     24685    -8     
========================================
+ Hits       314972    314974    +2     
+ Misses      73727     73693   -34     
  Partials      355       355           

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