Open
Conversation
Contributor
|
This PR has a migration; here is the generated SQL for for --
-- Create model SizeAnalysisSubscription
--
CREATE TABLE "sentry_sizeanalysissubscription" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "date_updated" timestamp with time zone NOT NULL, "date_added" timestamp with time zone NOT NULL, "project_id" bigint NOT NULL);
ALTER TABLE "sentry_sizeanalysissubscription" ADD CONSTRAINT "sentry_sizeanalysiss_project_id_41e3355e_fk_sentry_pr" FOREIGN KEY ("project_id") REFERENCES "sentry_project" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_sizeanalysissubscription" VALIDATE CONSTRAINT "sentry_sizeanalysiss_project_id_41e3355e_fk_sentry_pr";
CREATE INDEX CONCURRENTLY "sentry_sizeanalysissubscription_project_id_41e3355e" ON "sentry_sizeanalysissubscription" ("project_id"); |
a50e1e0 to
5317fb3
Compare
This was referenced Feb 13, 2026
5317fb3 to
affc2c2
Compare
affc2c2 to
258f072
Compare
| return self._extract_head(data_packet) - self._extract_base(data_packet) | ||
| case "relative_diff": | ||
| base = self._extract_base(data_packet) | ||
| return (self._extract_head(data_packet) - base) / base |
Contributor
There was a problem hiding this comment.
Bug: The extract_value method can cause a ZeroDivisionError when calculating a relative_diff because it divides by base without checking if base is zero.
Severity: MEDIUM
Suggested Fix
Before performing the division in extract_value, check if base is 0. If it is, return a sensible default value, similar to the pattern used in src/sentry/preprod/vcs/status_checks/size/tasks.py which returns False in this scenario.
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/preprod/size_analysis/grouptype.py#L127
Potential issue: In `PreprodSizeAnalysisDetectorHandler.extract_value()`, when
`threshold_type` is `"relative_diff"`, the code calculates a value by dividing by
`base`. However, the `_extract_base()` method does not prevent `base` from being `0`. If
a data packet results in a base size of 0, this will cause an unhandled
`ZeroDivisionError`, crashing the detector handler during evaluation. Similar code
elsewhere in the project explicitly checks for a zero base value, indicating this is a
known edge case that should be handled.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add PreprodSizeAnalysisGroupType (type_id=11003) with detector handler
and validators that integrate with the workflow engine to emit issues
when build size thresholds are exceeded.
comparisons and produces IssueOccurrences
PRs:
Design doc