Skip to content

ref: migrate security and privacy to new form system#109183

Merged
TkDodo merged 18 commits intomasterfrom
tkdodo/ref/de-942-migrate-security-privacy
Feb 25, 2026
Merged

ref: migrate security and privacy to new form system#109183
TkDodo merged 18 commits intomasterfrom
tkdodo/ref/de-942-migrate-security-privacy

Conversation

@TkDodo
Copy link
Collaborator

@TkDodo TkDodo commented Feb 24, 2026

note: there are more forms hidden behind “Advanced Data Scrubbing” modal (add / edit), I will do them in a separate PR.

@linear
Copy link

linear bot commented Feb 24, 2026

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Feb 24, 2026
@TkDodo TkDodo marked this pull request as ready for review February 24, 2026 14:54
@TkDodo TkDodo requested review from a team as code owners February 24, 2026 14:54
if (formId.startsWith('-')) {
formId = formId.slice(1);
}
// use filename, but if it's index.tsx, use the parent directory name instead
Copy link
Member

Choose a reason for hiding this comment

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

Once we are done with the migration, I would like to do a pass on the structure of these, there's a lot to cleanup 😓

# Conflicts:
#	static/app/components/core/form/generatedFieldRegistry.ts
</field.Layout.Row>
)}
</AutoSaveField>
)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Legacy storeCrashReports values lose formatted display

Low Severity

The old code included a placeholder hack specifically for organizations that have a legacy storeCrashReports value not present in the standard options list (e.g., a value like 3 instead of 0, 1, 5, 10, 20, 50, 100, -1). The old placeholder: ({value}) => formatStoreCrashReports(value) ensured these non-standard values displayed a human-readable label like "3 per issue." The new field.Select doesn't include this fallback, so organizations with legacy values will see either a blank select or a default placeholder instead of the formatted value.

Fix in Cursor Fix in Web

Comment on lines +400 to +401
const initialSensitiveFields = convertMultilineFieldValue(organization.sensitiveFields);
const initialSafeFields = convertMultilineFieldValue(organization.safeFields);
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: The form in ScrubbingConfigurationFieldGroup doesn't re-initialize when organization data changes, causing dirty checks and reset functionality to use stale initialSensitiveFields and initialSafeFields values.
Severity: MEDIUM

Suggested Fix

Use a useEffect hook to explicitly reset the form's state whenever the organization data changes. The effect should have organization.safeFields and organization.sensitiveFields in its dependency array and call a form reset method with the new initial values.

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/app/views/settings/organizationSecurityAndPrivacy/index.tsx#L400-L401

Potential issue: The `ScrubbingConfigurationFieldGroup` component recalculates
`initialSensitiveFields` and `initialSafeFields` on every render based on updated
organization data. However, the `useScrapsForm` hook does not update its internal state
with new `defaultValues` after its initial render. When another field saves and triggers
a re-render with new organization data, the form's dirty-check logic compares the user's
current input against the newly calculated initial values, not the ones present when
editing began. This leads to incorrect "unsaved changes" alerts and causes the "Cancel"
button to reset the form to the wrong state.

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

@TkDodo TkDodo enabled auto-merge (squash) February 25, 2026 09:11
Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.


const scrubbingConfiguration = useScrapsForm({
...defaultFormOptions,
formId: 'organization-settings-security-and-privacy',
Copy link
Contributor

Choose a reason for hiding this comment

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

Registry formId mismatches actual form formId

Low Severity

The formId in the scrubbing configuration form is 'organization-settings-security-and-privacy' (with -settings-), but the auto-generated generatedFieldRegistry.ts derives formId: 'organization-security-and-privacy' from the directory name. This mismatch means the registry keys for sensitiveFields and safeFields are inconsistent with the actual form's identity.

Additional Locations (1)

Fix in Cursor Fix in Web

@TkDodo TkDodo merged commit 54c4204 into master Feb 25, 2026
102 checks passed
@TkDodo TkDodo deleted the tkdodo/ref/de-942-migrate-security-privacy branch February 25, 2026 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants