Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/sentry/uptime/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ class IntervalSeconds(models.IntegerChoices):
# How to sample traces for this monitor. Note that we always send a trace_id, so any errors will
# be associated, this just controls the span sampling.
trace_sampling = models.BooleanField(default=False, db_default=False)
# Test field to verify CI catches missing migrations
test_migration_check = models.CharField(max_length=100, null=True, default=None)
Copy link
Contributor

Choose a reason for hiding this comment

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

Test field without migration should not be merged

High Severity

A test field test_migration_check has been added to the UptimeSubscription model without a corresponding migration file. The comment explicitly states this is a "Test field to verify CI catches missing migrations." This is test/debugging code that should not be merged to production. If deployed, the model would reference a database column that doesn't exist, causing runtime errors when accessing UptimeSubscription records.

Fix in Cursor Fix in Web


objects: ClassVar[BaseManager[Self]] = BaseManager(
cache_fields=["pk", "subscription_id"],
Copy link

Choose a reason for hiding this comment

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

Bug: The UptimeSubscription model was changed by adding the test_migration_check field, but no corresponding database migration was generated.
Severity: CRITICAL

Suggested Fix

Generate a new migration file to reflect the changes in the UptimeSubscription model. This can be done by running the command python manage.py makemigrations uptime and committing the resulting migration file.

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/uptime/models.py#L99

Potential issue: A new field `test_migration_check` has been added to the
`UptimeSubscription` model, but a corresponding database migration file has not been
created. When code attempts to create or update an `UptimeSubscription` instance, the
Django ORM will generate an SQL query that includes the new field. Because the
`test_migration_check` column does not exist in the database schema, the database will
reject the query, leading to a `django.db.utils.ProgrammingError` at runtime.

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

Expand Down
Loading