Skip to content

feat(investigations): add the investigation template registry [3/13] - #121403

Merged
wedamija merged 3 commits into
masterfrom
investigations/03-contracts
Aug 10, 2026
Merged

feat(investigations): add the investigation template registry [3/13]#121403
wedamija merged 3 commits into
masterfrom
investigations/03-contracts

Conversation

@arslnb

@arslnb arslnb commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Add the code-owned, versioned template registry used by Investigation creation, plus the first breached-metric template. Templates are declarative specs with no database or service logic; instantiation comes in the next PR.

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Aug 6, 2026
@sentry

This comment was marked as outdated.

@arslnb
arslnb marked this pull request as ready for review August 6, 2026 06:54
Comment thread src/sentry/investigations/serializers/investigation.py Outdated
@arslnb
arslnb force-pushed the investigations/02-platform branch from 0d083db to e42180f Compare August 6, 2026 07:22
@arslnb
arslnb force-pushed the investigations/03-contracts branch from 2e1c19d to b9518b1 Compare August 6, 2026 07:22
Comment thread src/sentry/investigations/serializers/investigation.py Outdated
@arslnb
arslnb force-pushed the investigations/02-platform branch from e42180f to 3bdb176 Compare August 6, 2026 07:36
@arslnb
arslnb force-pushed the investigations/03-contracts branch from b9518b1 to 1dadf6c Compare August 6, 2026 07:36
Comment thread src/sentry/investigations/contracts.py Outdated
Comment thread src/sentry/investigations/serializers/investigation.py Outdated
Comment thread src/sentry/investigations/contracts.py Outdated
Comment thread src/sentry/investigations/serializers/investigation.py Outdated
@arslnb
arslnb force-pushed the investigations/02-platform branch from 3bdb176 to 91b7a90 Compare August 6, 2026 08:17
@arslnb
arslnb force-pushed the investigations/03-contracts branch from 1dadf6c to 6483bde Compare August 6, 2026 08:17
Comment thread src/sentry/investigations/serializers/investigation.py Outdated
@github-actions

This comment was marked as outdated.

@arslnb
arslnb force-pushed the investigations/02-platform branch from 91b7a90 to d729b2e Compare August 6, 2026 19:22
@arslnb
arslnb requested review from a team as code owners August 6, 2026 19:22
@arslnb
arslnb force-pushed the investigations/03-contracts branch from 6483bde to 4a7acf2 Compare August 6, 2026 19:22
Comment thread src/sentry/investigations/serializers/investigation.py Outdated
Comment thread src/sentry/investigations/serializers/investigation.py Outdated
cursor[bot]

This comment was marked as outdated.

@arslnb
arslnb force-pushed the investigations/02-platform branch from d729b2e to ec4feee Compare August 6, 2026 21:38
@arslnb
arslnb force-pushed the investigations/03-contracts branch from 4a7acf2 to ded6311 Compare August 6, 2026 21:38
Comment thread src/sentry/investigations/serializers/investigation.py Outdated
@arslnb arslnb changed the title feat(investigations): add contracts and serializers [3/14] feat(investigations): add contracts and serializers Aug 6, 2026
@arslnb
arslnb marked this pull request as draft August 6, 2026 22:14
@arslnb arslnb changed the title [3/14] feat(investigations): add contracts and serializers feat(investigations): add contracts and serializers [3/14] Aug 6, 2026
Base automatically changed from investigations/02-platform to master August 7, 2026 19:08
@arslnb
arslnb force-pushed the investigations/03-contracts branch from ded6311 to d8aeed0 Compare August 7, 2026 19:45
@arslnb
arslnb changed the base branch from master to investigations/02-5-block-schema August 7, 2026 19:45
@arslnb
arslnb force-pushed the investigations/03-contracts branch from d8aeed0 to 49c1ca2 Compare August 7, 2026 19:48
Base automatically changed from investigations/02-5-block-schema to master August 7, 2026 20:56
@wedamija
wedamija force-pushed the investigations/03-contracts branch from 49c1ca2 to af9440a Compare August 7, 2026 21:24
Comment thread src/sentry/investigations/endpoints/serializers/block.py Outdated
@wedamija wedamija changed the title feat(investigations): add contracts and serializers [3/14] feat(investigations): add the investigation template registry Aug 7, 2026
@wedamija
wedamija marked this pull request as ready for review August 7, 2026 23:12
@wedamija
wedamija force-pushed the investigations/03-contracts branch from 66f9e52 to 9c13a6e Compare August 8, 2026 00:15
Comment on lines +20 to +30
key: str
kind: str
title: str
content: str = ""
generation_prompt: str = ""
generated_content: str = ""
config: dict[str, Any] = field(default_factory=dict)
display: dict[str, Any] = field(default_factory=dict)
dependencies: tuple[str, ...] = ()
parameters: tuple[str, ...] = ()

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 frozen=True dataclasses TemplateBlockSpec and TemplateParameterSpec are unhashable because they contain dict fields, which will cause a TypeError if they are ever used in sets or as dict keys.
Severity: LOW

Suggested Fix

To make the dataclasses hashable as intended by frozen=True, convert the dict fields to an immutable type. For example, change dict[str, Any] to MappingProxyType[str, Any] and ensure the dictionary is wrapped in MappingProxyType during initialization. This preserves the immutable intent while making the objects correctly hashable.

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/investigations/templates/types.py#L18-L30

Potential issue: The dataclasses `TemplateBlockSpec` and `TemplateParameterSpec` are
defined with `frozen=True`, which implicitly generates a `__hash__` method. However,
these classes contain fields of type `dict` (`config`, `display`, `constraints`), which
are unhashable. Any attempt to add instances of these classes to a set or use them as
dictionary keys will result in a `TypeError: unhashable type: 'dict'`. While the current
pull request does not perform any hashing operations on these objects, this design
creates a latent bug that will likely cause runtime crashes in future code that handles
instantiation, caching, or deduplication of these spec objects.

Also affects:

  • src/sentry/investigations/templates/types.py:7~16

wedamija added a commit that referenced this pull request Aug 10, 2026
Split this out from #121403 to
keep the size down.

This implements validators (ie drf serializers) and contracts (drf
serializers for validating seer output) for use in later stacked prs.

<!-- Describe your PR here. -->
wedamija added a commit that referenced this pull request Aug 10, 2026
This splits out the response serializers from #121403 to keep the total pr size down, and restructures them into separate folders.
@arslnb

arslnb commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

LGTM!

@wedamija
wedamija merged commit af4cea5 into master Aug 10, 2026
65 checks passed
@wedamija
wedamija deleted the investigations/03-contracts branch August 10, 2026 19:02
wedamija added a commit that referenced this pull request Aug 10, 2026
This splits out the response serializers from
#121403 to keep the total pr
size down, and restructures them into separate folders.

<!-- Describe your PR here. -->
@arslnb arslnb changed the title feat(investigations): add the investigation template registry feat(investigations): add the investigation template registry [3/13] Aug 10, 2026
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