-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
feat(aci): automation edit scaffolding #94595
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
Conversation
return availableActions.find( | ||
handler => | ||
handler.type === ActionType.SENTRY_APP && | ||
((action.config.sentry_app_identifier === SentryAppIdentifier.SENTRY_APP_ID && | ||
action.config.target_identifier === handler.sentryApp?.id) || | ||
(action.config.sentry_app_identifier === | ||
SentryAppIdentifier.SENTRY_APP_INSTALLATION_UUID && | ||
action.config.target_identifier === handler.sentryApp?.installationUuid)) | ||
); |
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 is difficult to read
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: State Initialization Vulnerabilities in AutomationBuilder
The AutomationBuilderState
initialization in edit.tsx
has two issues. Firstly, actionFilters
is directly assigned automation.actionFilters
without a fallback to a default array (unlike triggers
), which can result in actionFilters
being undefined
and violating its expected array type. Secondly, the useAutomationBuilderReducer
hook is initialized with initialState
derived from automation
. Although the current conditional rendering prevents the reducer from being initialized with an undefined
state (as the form only mounts after automation
data loads), this pattern is fragile and could lead to an empty default state if loading conditions change.
static/app/views/automations/edit.tsx#L81-L95
sentry/static/app/views/automations/edit.tsx
Lines 81 to 95 in b159165
const initialState = useMemo((): AutomationBuilderState | undefined => { | |
if (!automation) { | |
return undefined; | |
} | |
return { | |
triggers: automation.triggers | |
? automation.triggers | |
: initialAutomationBuilderState.triggers, | |
actionFilters: automation.actionFilters, | |
}; | |
}, [automation]); | |
const model = useMemo(() => new FormModel(), []); | |
const {state, actions} = useAutomationBuilderReducer(initialState); |
Was this report helpful? Give feedback by reacting with 👍 or 👎
we can also remove
flattie
now since we're maintaining automation builder state outside of the form