Skip to content

feat(uptime): backfill 2xx status code assertions on all uptime subscriptions#108678

Merged
evanpurkhiser merged 1 commit intomasterfrom
evanpurkhiser/feat-uptime-backfill-2xx-status-code-assertions-on-all-uptime-subscriptions
Mar 16, 2026
Merged

feat(uptime): backfill 2xx status code assertions on all uptime subscriptions#108678
evanpurkhiser merged 1 commit intomasterfrom
evanpurkhiser/feat-uptime-backfill-2xx-status-code-assertions-on-all-uptime-subscriptions

Conversation

@evanpurkhiser
Copy link
Copy Markdown
Member

Fixes NEW-761

@evanpurkhiser evanpurkhiser requested review from a team as code owners February 20, 2026 11:38
@evanpurkhiser evanpurkhiser removed the request for review from a team February 20, 2026 11:38
@linear
Copy link
Copy Markdown

linear bot commented Feb 20, 2026

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Feb 20, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This PR has a migration; here is the generated SQL for src/sentry/uptime/migrations/0055_backfill_2xx_status_assertion.py

for 0055_backfill_2xx_status_assertion in uptime

--
-- Raw Python operation
--
-- THIS OPERATION CANNOT BE WRITTEN AS SQL

Copy link
Copy Markdown
Member

@wedamija wedamija left a comment

Choose a reason for hiding this comment

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

Is adding this check to all uptime checks going to make these more expensive to run at all?

Comment on lines +40 to +45
if not assertion or not assertion.get("root"):
return {"root": {"op": "and", "children": copy.deepcopy(DEFAULT_STATUS_CODE_CHECKS)}}, True

root = assertion["root"]
if _has_any_status_code_check(root):
return assertion, False
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wondering if we should just check for no assertion here, rather than editing existing assertions? Are customers using these at all right now? It might be easier to just handle the simple case

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Let me double check.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

OK so

  -- How many have custom assertions beyond just status_code_check
  SELECT COUNT(*) AS has_custom_assertions
  FROM uptime_uptimesubscription
  WHERE assertion IS NOT NULL
    AND EXISTS (
      SELECT 1
      FROM jsonb_array_elements(assertion->'root'->'children') AS child
      WHERE child->>'op' != 'status_code_check'
    );

There's only 22 where the customer has changed the assertions from starting with the status code assertion.

If we don't make the edits we might end up losing the assertion checks and confusing customers when we allow 500s without assertions.

@evanpurkhiser evanpurkhiser force-pushed the evanpurkhiser/feat-uptime-backfill-2xx-status-code-assertions-on-all-uptime-subscriptions branch from 46d929f to 35ab3a3 Compare March 16, 2026 19:36
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 16, 2026

Backend Test Failures

Failures on be91152 in this run:

tests/sentry/spans/test_buffer.py::test_schema_examples[cluster-nochunk-span_with_accepted_outcome]log
tests/sentry/spans/test_buffer.py:1616: in test_schema_examples
    span = Span(
E   TypeError: Span.__new__() got an unexpected keyword argument 'end_timestamp'
tests/sentry/spans/test_buffer.py::test_schema_examples[single-chunk1-basic_span]log
tests/sentry/spans/test_buffer.py:1616: in test_schema_examples
    span = Span(
E   TypeError: Span.__new__() got an unexpected keyword argument 'end_timestamp'
tests/sentry/spans/test_buffer.py::test_schema_examples[cluster-nochunk-null_fields]log
tests/sentry/spans/test_buffer.py:1616: in test_schema_examples
    span = Span(
E   TypeError: Span.__new__() got an unexpected keyword argument 'end_timestamp'
tests/sentry/spans/test_buffer.py::test_schema_examples[single-nochunk-basic_span]log
tests/sentry/spans/test_buffer.py:1616: in test_schema_examples
    span = Span(
E   TypeError: Span.__new__() got an unexpected keyword argument 'end_timestamp'
tests/sentry/spans/test_buffer.py::test_schema_examples[single-chunk1-span_with_accepted_outcome]log
tests/sentry/spans/test_buffer.py:1616: in test_schema_examples
    span = Span(
E   TypeError: Span.__new__() got an unexpected keyword argument 'end_timestamp'
tests/sentry/spans/test_buffer.py::test_schema_examples[single-nochunk-null_fields]log
tests/sentry/spans/test_buffer.py:1616: in test_schema_examples
    span = Span(
E   TypeError: Span.__new__() got an unexpected keyword argument 'end_timestamp'
tests/sentry/spans/test_buffer.py::test_schema_examples[cluster-nochunk-basic_span]log
tests/sentry/spans/test_buffer.py:1616: in test_schema_examples
    span = Span(
E   TypeError: Span.__new__() got an unexpected keyword argument 'end_timestamp'
tests/sentry/spans/test_buffer.py::test_schema_examples[single-chunk1-null_fields]log
tests/sentry/spans/test_buffer.py:1616: in test_schema_examples
    span = Span(
E   TypeError: Span.__new__() got an unexpected keyword argument 'end_timestamp'
tests/sentry/spans/test_buffer.py::test_schema_examples[cluster-chunk1-span_with_accepted_outcome]log
tests/sentry/spans/test_buffer.py:1616: in test_schema_examples
    span = Span(
E   TypeError: Span.__new__() got an unexpected keyword argument 'end_timestamp'
tests/sentry/spans/test_buffer.py::test_schema_examples[cluster-chunk1-basic_span]log
tests/sentry/spans/test_buffer.py:1616: in test_schema_examples
    span = Span(
E   TypeError: Span.__new__() got an unexpected keyword argument 'end_timestamp'
tests/sentry/spans/test_buffer.py::test_schema_examples[single-nochunk-span_with_accepted_outcome]log
tests/sentry/spans/test_buffer.py:1616: in test_schema_examples
    span = Span(
E   TypeError: Span.__new__() got an unexpected keyword argument 'end_timestamp'
tests/sentry/spans/test_buffer.py::test_schema_examples[cluster-chunk1-null_fields]log
tests/sentry/spans/test_buffer.py:1616: in test_schema_examples
    span = Span(
E   TypeError: Span.__new__() got an unexpected keyword argument 'end_timestamp'

@evanpurkhiser evanpurkhiser force-pushed the evanpurkhiser/feat-uptime-backfill-2xx-status-code-assertions-on-all-uptime-subscriptions branch from 35ab3a3 to 963458c Compare March 16, 2026 20:23
@evanpurkhiser evanpurkhiser enabled auto-merge (squash) March 16, 2026 20:28
@evanpurkhiser evanpurkhiser merged commit 312c7d2 into master Mar 16, 2026
79 checks passed
@evanpurkhiser evanpurkhiser deleted the evanpurkhiser/feat-uptime-backfill-2xx-status-code-assertions-on-all-uptime-subscriptions branch March 16, 2026 20:48
JonasBa pushed a commit that referenced this pull request Mar 16, 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