Skip to content

fix(models): Break infinite recursion in GroupHash repr#110902

Merged
bmckerry merged 1 commit intomasterfrom
fix-recursion-grouphash
Mar 17, 2026
Merged

fix(models): Break infinite recursion in GroupHash repr#110902
bmckerry merged 1 commit intomasterfrom
fix-recursion-grouphash

Conversation

@bmckerry
Copy link
Member

Break a mutual recursion between GroupHash.repr and GroupHashMetadata.repr that causes a RecursionError and a storm of database queries.

The cycle: GroupHashMetadata.repr accesses seer_matched_grouphash (lazy-loads a GroupHash), whose repr accesses metadata (lazy-loads a GroupHashMetadata via reverse OneToOneField), whose repr accesses seer_matched_grouphash... and so on until Python hits the recursion limit. This is triggered by the Sentry SDK's Django caching integration calling str() on cached model instances to measure their size.

Two changes to break the cycle from both sides:

  • GroupHashMetadata: use seer_matched_grouphash_id (raw FK column) instead of seer_matched_grouphash (related object) in sane_repr — avoids the lazy load entirely
  • GroupHash: remove metadata from sane_repr — it triggered a reverse OneToOneField query on every repr call

@bmckerry bmckerry requested review from a team as code owners March 17, 2026 19:02
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 17, 2026
@bmckerry bmckerry marked this pull request as draft March 17, 2026 19:04
@bmckerry bmckerry marked this pull request as ready for review March 17, 2026 19:07
@bmckerry bmckerry merged commit eed9c8a into master Mar 17, 2026
79 checks passed
@bmckerry bmckerry deleted the fix-recursion-grouphash branch March 17, 2026 19:28
s1gr1d added a commit to getsentry/craft that referenced this pull request Mar 20, 2026
…sh (#777)

A package was published to the release registry without `main_docs_url`
set. Now, we use `repo_url` as `mainDocsUrl` fallback and emit warnings
on missing metadata.

Related Sentry PR: getsentry/sentry#110902

This PR adds upfront validation warnings and clearer, rewritten
documentation for all config options (the diff looks big as I ran
prettier).

### Validation

For all new packages (apps, SDKs), it checks:
- `name`
- `mainDocsUrl` (can also use the fallback value of `repo_url`)

When an `sdkName` is provided, we can safely assume that a new SDK will
be added and we additionally check for `packageUrl`.

In case of missing options, the workflow will fail -> avoids incorrect
registry states.

---------

Co-authored-by: getsentry-bot <[email protected]>
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