diff --git a/web/app/components/plugins/plugin-detail-panel/app-selector/hooks/use-app-inputs-form-schema.ts b/web/app/components/plugins/plugin-detail-panel/app-selector/hooks/use-app-inputs-form-schema.ts index da35bcf173..4556e7534c 100644 --- a/web/app/components/plugins/plugin-detail-panel/app-selector/hooks/use-app-inputs-form-schema.ts +++ b/web/app/components/plugins/plugin-detail-panel/app-selector/hooks/use-app-inputs-form-schema.ts @@ -205,7 +205,12 @@ export function useAppInputsFormSchema({ if (!currentApp) return [] + // For workflow apps, wait until workflow data is available + if (!isBasicApp && !currentWorkflow) + return [] + // Build base schema based on app type + // Note: currentWorkflow is guaranteed to be defined here due to the early return above const baseSchema = isBasicApp ? buildBasicAppSchema(currentApp, fileUploadConfig) : buildWorkflowSchema(currentWorkflow!, fileUploadConfig) diff --git a/web/app/components/plugins/plugin-detail-panel/subscription-list/create/hooks/use-common-modal-state.ts b/web/app/components/plugins/plugin-detail-panel/subscription-list/create/hooks/use-common-modal-state.ts index e979fecc27..b01312d3d1 100644 --- a/web/app/components/plugins/plugin-detail-panel/subscription-list/create/hooks/use-common-modal-state.ts +++ b/web/app/components/plugins/plugin-detail-panel/subscription-list/create/hooks/use-common-modal-state.ts @@ -237,6 +237,15 @@ export const useCommonModalState = ({ // Handle verify const handleVerify = useCallback(() => { + // Guard against uninitialized state + if (!detail?.provider || !subscriptionBuilder?.id) { + Toast.notify({ + type: 'error', + message: 'Subscription builder not initialized', + }) + return + } + const apiKeyCredentialsFormValues = apiKeyCredentialsFormRef.current?.getFormValues({}) || DEFAULT_FORM_VALUES const credentials = apiKeyCredentialsFormValues.values @@ -255,8 +264,8 @@ export const useCommonModalState = ({ verifyCredentials( { - provider: detail?.provider || '', - subscriptionBuilderId: subscriptionBuilder?.id || '', + provider: detail.provider, + subscriptionBuilderId: subscriptionBuilder.id, credentials, }, { diff --git a/web/app/components/plugins/plugin-detail-panel/subscription-list/create/hooks/use-oauth-client-state.ts b/web/app/components/plugins/plugin-detail-panel/subscription-list/create/hooks/use-oauth-client-state.ts index d0b610a388..77e651a485 100644 --- a/web/app/components/plugins/plugin-detail-panel/subscription-list/create/hooks/use-oauth-client-state.ts +++ b/web/app/components/plugins/plugin-detail-panel/subscription-list/create/hooks/use-oauth-client-state.ts @@ -164,11 +164,18 @@ export const useOAuthClientState = ({ } if (isCustom) { + // Short-circuit if no schema to validate + if (!oauthClientSchema?.length) { + return + } + const clientFormValues = clientFormRef.current?.getFormValues({}) as { values: TriggerOAuthClientParams isCheckValidated: boolean - } - if (!clientFormValues.isCheckValidated) + } | undefined + + // Handle missing ref or form values + if (!clientFormValues || !clientFormValues.isCheckValidated) return const clientParams = { ...clientFormValues.values } @@ -194,7 +201,7 @@ export const useOAuthClientState = ({ }) }, }) - }, [clientType, providerName, oauthConfig?.params, configureOAuth, handleAuthorization, onClose, t]) + }, [clientType, providerName, oauthClientSchema, oauthConfig?.params, configureOAuth, handleAuthorization, onClose, t]) // Polling effect for authorization verification useEffect(() => {