Skip to content

ref(forms): Migrate Sentry App schema forms to BackendJsonSubmitForm#112911

Closed
priscilawebdev wants to merge 8 commits intomasterfrom
priscila/ref/backend-json-form-custom-async
Closed

ref(forms): Migrate Sentry App schema forms to BackendJsonSubmitForm#112911
priscilawebdev wants to merge 8 commits intomasterfrom
priscila/ref/backend-json-form-custom-async

Conversation

@priscilawebdev
Copy link
Copy Markdown
Member

@priscilawebdev priscilawebdev commented Apr 14, 2026

Migrate the Sentry App schema-backed forms to BackendJsonSubmitForm

SentryAppExternalForm becomes a function component and renders via BackendJsonSubmitForm. Both consumers (SentryAppExternalIssueForm, SentryAppRuleModal) keep going through the same Sentry App schema form path.

Add a customAsyncQueryOptions prop on BackendJsonSubmitForm so consumers can override the default URL-based async-select fetcher. The Sentry App external-requests endpoint expects {uri, query, dependentData}, which doesn't fit the adapter's built-in shape — this is the actual consumer the prop was added for.

Preserve legacy behavior: dependent field loading and resets, backend-provided default values, saved labels for async selects, the alert-rule submit payload shape, and form reset on action prop change.

Defer required-field validation to the form's auto-generated zod schema. The submit button stays enabled; clicking surfaces inline per-field errors via aria-invalid, matching the pattern in ticketRuleModal and externalIssueForm.

closes https://linear.app/getsentry/issue/DE-1055/sentry-app-schema-forms-custom-uris

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 14, 2026
@priscilawebdev priscilawebdev force-pushed the priscila/ref/backend-json-form-custom-async branch from 14cbb3c to 80254d0 Compare April 14, 2026 12:37
@sentry
Copy link
Copy Markdown
Contributor

sentry Bot commented Apr 14, 2026

Sentry Snapshot Testing

Name Added Removed Modified Renamed Unchanged Status
sentry-frontend
sentry-frontend
0 0 0 0 204 ✅ Unchanged

@priscilawebdev priscilawebdev force-pushed the priscila/ref/backend-json-form-custom-async branch from 80254d0 to 4d2cf8e Compare April 23, 2026 07:59
@priscilawebdev priscilawebdev changed the title ref(forms): Add customAsyncQueryOptions to BackendJsonSubmitForm ref(forms): Migrate Sentry App schema forms to BackendJsonSubmitForm Apr 23, 2026
@linear-code
Copy link
Copy Markdown

linear-code Bot commented Apr 23, 2026

Migrate the Sentry App schema-backed forms (issue-link and
alert-rule-action) off FormModel/FieldFromConfig and onto
BackendJsonSubmitForm. SentryAppExternalForm becomes a function
component; both consumers (SentryAppExternalIssueForm,
SentryAppRuleModal) switch to the named export.

Add a customAsyncQueryOptions prop on BackendJsonSubmitForm so
consumers can override the default URL-based async-select fetcher.
The Sentry App external-requests endpoint expects {uri, query,
dependentData} which doesn't fit the adapter's built-in shape, and
this is the actual consumer the prop was added for.

Add an onValueChange callback so the migration can mirror every
field change into its own ref/state for dependent-field tracking,
distinct from onFieldChange (which only fires for updatesForm fields).

Preserve legacy behavior where it matters: depends_on dependent
field loading and resets, backend-provided default values, saved
labels for async selects, alert-rule submit payload shape, and the
form reset on action prop change.

Defer required-field validation to the form's auto-generated zod
schema. The submit button stays enabled; clicking surfaces inline
per-field errors via aria-invalid + the design-system warning icon,
matching the pattern in ticketRuleModal and externalIssueForm.

Refs DE-1055
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@priscilawebdev priscilawebdev force-pushed the priscila/ref/backend-json-form-custom-async branch from 5272e2f to 73a5270 Compare April 27, 2026 11:27
@priscilawebdev
Copy link
Copy Markdown
Member Author

priscilawebdev commented Apr 27, 2026

bugbot run

@priscilawebdev priscilawebdev requested review from a team as code owners April 27, 2026 11:53
Comment thread static/app/views/settings/organizationIntegrations/sentryAppExternalForm.tsx Outdated
Resolve schema defaults and request payload inputs by value so the initialization effect only reruns when the form semantics change. This avoids clearing dependent field state when callers rerender with equivalent callback and object props.

Memoize the issue-link and alert-rule callers that were recreating those props on every render and add a rerender regression test for dependent field prefetches.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
Comment thread static/app/views/settings/organizationIntegrations/sentryAppExternalForm.tsx Outdated
Comment thread static/app/components/group/sentryAppExternalIssueForm.tsx Outdated
Keep the rerender reset protection in SentryAppExternalForm while moving the issue-link and alert-rule callers back to inline props. This keeps the change focused on the shared form instead of spreading memoization churn across wrappers.

Replace the JSON parse normalization with a small serialized-value memo helper so equivalent object props still compare by value without the extra parse step.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
Comment thread static/app/views/settings/organizationIntegrations/sentryAppExternalForm.tsx Outdated
Comment thread static/app/views/settings/organizationIntegrations/sentryAppExternalForm.tsx Outdated
@priscilawebdev
Copy link
Copy Markdown
Member Author

bugbot run

Keep dependent field refreshes from overwriting newer form input by invalidating stale async responses and rebuilding remount values from the latest live form state.

Also normalize async select choice values before caching labels and forward textarea autosize metadata through the adapter so migrated schema forms keep their intended behavior.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
@priscilawebdev priscilawebdev force-pushed the priscila/ref/backend-json-form-custom-async branch from 203f1fd to 6cd0388 Compare April 28, 2026 07:50
@priscilawebdev
Copy link
Copy Markdown
Member Author

bugbot run

Copy link
Copy Markdown
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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 6cd0388. Configure here.

@priscilawebdev
Copy link
Copy Markdown
Member Author

This PR got a bit out of hand. I tested everything manually and it seems to work well, but it’s become hard to follow and review. I’m going to close it for now.

…d-json-form-custom-async

# Conflicts:
#	static/app/components/backendJsonFormAdapter/backendJsonSubmitForm.tsx
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

📊 Type Coverage Diff

Metric Before After Delta
Coverage 93.44% 93.46% 🟢 +0.02%
Typed 134,935 135,060 🟢 +125
Untyped 9,473 9,444 🟢 -29
🔍 8 new type safety issues introduced

any-typed symbols (5 new)

File Line Detail
static/app/views/settings/organizationIntegrations/sentryAppExternalForm.tsx 377 response (var)
static/app/views/settings/organizationIntegrations/sentryAppExternalForm.tsx 432 results (var)
static/app/views/settings/organizationIntegrations/sentryAppExternalForm.tsx 452 result (var)
static/app/views/settings/organizationIntegrations/sentryAppExternalForm.tsx 687 results (var)
static/app/views/settings/organizationIntegrations/sentryAppExternalForm.tsx 707 result (var)

Type assertions (as) (3 new)

File Line Detail
static/app/views/settings/organizationIntegrations/sentryAppExternalForm.tsx 140 as [string, string][String(value), choiceLabelToString(label)] as [string, string]
static/app/views/settings/organizationIntegrations/sentryAppExternalForm.tsx 383 as Choicesresponse.choices as Choices
static/app/views/settings/organizationIntegrations/sentryAppExternalForm.tsx 626 as [string, string][String(value), choiceLabelToString(label)] as [string, string]

This is informational only and does not block the PR.

priscilawebdev added a commit that referenced this pull request May 6, 2026
Register the `organizations:sentry-app-schema-form-migration` feature
flag.

Refs #112911

---------

Co-authored-by: Claude <noreply@anthropic.com>
priscilawebdev added a commit that referenced this pull request May 6, 2026
Restore the pre-migration class component as sentryAppExternalForm.legacy.tsx
(exported as LegacySentryAppExternalForm) and have the two consumers —
SentryAppExternalIssueForm and SentryAppRuleModal — pick between the
legacy and new form based on the organizations:sentry-app-schema-form-migration
flag.

Add Sentry.captureException to the new form's two failure paths so we can
observe issues during rollout:
  - Save: onError of the create-external-issue mutation
  - Edit: dependent-field initialization (Promise.all of fetchFieldChoices
    when the form opens)

The flag is registered in #114945 and rolled out via
getsentry/sentry-options-automator#7678.

Refs DE-1055
Refs #114945
Refs #112911
Co-Authored-By: Claude <noreply@anthropic.com>
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.

1 participant