-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat(billing): update org retention settings in _admin #103126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: vbro_add_orgretention_to_subscription
Are you sure you want to change the base?
feat(billing): update org retention settings in _admin #103126
Conversation
| standard: orgStandard === '' ? null : Number(orgStandard), | ||
| downsampled: null, | ||
| }; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: If orgRetention.standard is null and the "Org Retention" field is untouched, form submission incorrectly converts null to 0.
Severity: HIGH | Confidence: 0.95
🔍 Detailed Analysis
When a subscription has orgRetention.standard = null and a user opens the modal without modifying the "Org Retention" field, the form submission incorrectly converts null to 0. This happens because Number(null) evaluates to 0. This changes the customer's retention configuration unintentionally, as null signifies using the plan's default retention, while 0 explicitly sets retention to zero.
💡 Suggested Fix
Update the submission logic for orgRetention.standard to explicitly check for null values. Change orgStandard === '' ? null : Number(orgStandard) to orgStandard === '' || orgStandard === null ? null : Number(orgStandard).
🤖 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: static/gsAdmin/components/customers/updateRetentionSettingsModal.tsx#L86-L89
Potential issue: When a subscription has `orgRetention.standard = null` and a user opens
the modal without modifying the "Org Retention" field, the form submission incorrectly
converts `null` to `0`. This happens because `Number(null)` evaluates to `0`. This
changes the customer's retention configuration unintentionally, as `null` signifies
using the plan's default retention, while `0` explicitly sets retention to zero.
Did we get this right? 👍 / 👎 to inform future reviews.
| const orgRetention = { | ||
| standard: orgStandard === '' ? null : Number(orgStandard), | ||
| downsampled: null, | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Empty Field Values Mapped Inconsistently
The orgRetention.standard value is inconsistently handled when the field is cleared. If orgStandard is null (when the field starts empty and isn't modified), Number(null) converts it to 0 instead of null. If orgStandard is '' (when a filled field is cleared), it correctly becomes null. This creates different behavior for the same user action (clearing the field) based on the initial value, violating the expected semantics where empty fields should consistently map to null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is outdated.

This allows org-level retention setting to be updated in _admin. Update of per-category retention settings is already supported in _admin.
This PR is stacked on top of #103118, and is a follow up to https://github.com/getsentry/getsentry/pull/18800