Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(data-warehouse): stop duplicate account-load toast in the source wizard (#110473)

Tom Owers25fbcaec825b
diff --git a/frontend/src/initKea.ts b/frontend/src/initKea.ts
index ccdc966d8521..8b60fa9fa5c1 100644
--- a/frontend/src/initKea.ts
+++ b/frontend/src/initKea.ts
@@ -92,6 +92,8 @@ const ERROR_FILTER_ALLOW_LIST = [
'loadLineage', // MetricLineagePanel renders every failure class itself, including the not-ready 404
'loadSourceDocuments', // The knowledge source page renders its own retry banner for the indexed page list
'loadTableDetails', // The model detail summary renders its own error state with a retry
+ 'loadIntegrationAccounts', // The source wizard's account picker shows the error under the field with a reconnect link
+ 'loadCredentialAccounts', // Fires while the user types credentials; the account picker shows the error under the field
]
/*
diff --git a/frontend/src/lib/integrations/credentialAccountsLogic.ts b/frontend/src/lib/integrations/credentialAccountsLogic.ts
index 2ec8c4fc114a..b1f7157a1ae3 100644
--- a/frontend/src/lib/integrations/credentialAccountsLogic.ts
+++ b/frontend/src/lib/integrations/credentialAccountsLogic.ts
@@ -19,15 +19,15 @@ export interface credentialAccountsLogicValues {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface credentialAccountsLogicActions {
- loadAccounts: () => any
- loadAccountsFailure: (
+ loadCredentialAccounts: () => any
+ loadCredentialAccountsFailure: (
error: string,
errorObject?: any
) => {
error: string
errorObject?: any
}
- loadAccountsSuccess: (
+ loadCredentialAccountsSuccess: (
accounts: IntegrationAccountApi[],
payload?: any
) => {
@@ -76,7 +76,7 @@ export const credentialAccountsLogic = kea<credentialAccountsLogicType>([
accounts: [
[] as IntegrationAccountApi[],
{
- loadAccounts: async () => {
+ loadCredentialAccounts: async () => {
const response = await externalDataSourcesCredentialAccountsCreate(
String(ApiConfig.getCurrentProjectId()),
{
@@ -97,8 +97,8 @@ export const credentialAccountsLogic = kea<credentialAccountsLogicType>([
accountsLoaded: [
false,
{
- loadAccountsSuccess: () => true,
- loadAccountsFailure: () => true,
+ loadCredentialAccountsSuccess: () => true,
+ loadCredentialAccountsFailure: () => true,
},
],
// The backend turns a provider rejection into an actionable 400 (a key it won't accept, a
@@ -106,9 +106,9 @@ export const credentialAccountsLogic = kea<credentialAccountsLogicType>([
accountsError: [
null as string | null,
{
- loadAccounts: () => null,
- loadAccountsSuccess: () => null,
- loadAccountsFailure: (_, { error, errorObject }) =>
+ loadCredentialAccounts: () => null,
+ loadCredentialAccountsSuccess: () => null,
+ loadCredentialAccountsFailure: (_, { error, errorObject }) =>
errorObject?.data?.detail ?? errorObject?.detail ?? error ?? null,
},
],
@@ -119,7 +119,7 @@ export const credentialAccountsLogic = kea<credentialAccountsLogicType>([
// Longer than the OAuth logic's search debounce: this fires while the user is still
// typing credentials, and each attempt costs a token exchange against the provider.
await breakpoint(CREDENTIALS_DEBOUNCE_MS)
- actions.loadAccounts()
+ actions.loadCredentialAccounts()
},
})),
])
diff --git a/frontend/src/lib/integrations/integrationAccountsLogic.ts b/frontend/src/lib/integrations/integrationAccountsLogic.ts
index 3bb311fe9042..23bed809a12c 100644
--- a/frontend/src/lib/integrations/integrationAccountsLogic.ts
+++ b/frontend/src/lib/integrations/integrationAccountsLogic.ts
@@ -19,15 +19,15 @@ export interface integrationAccountsLogicValues {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface integrationAccountsLogicActions {
- loadAccounts: () => any
- loadAccountsFailure: (
+ loadIntegrationAccounts: () => any
+ loadIntegrationAccountsFailure: (
error: string,
errorObject?: any
) => {
error: string
errorObject?: any
}
- loadAccountsSuccess: (
+ loadIntegrationAccountsSuccess: (
accounts: IntegrationAccountApi[],
payload?: any
) => {
@@ -70,7 +70,7 @@ export const integrationAccountsLogic = kea<integrationAccountsLogicType>([
accounts: [
[] as IntegrationAccountApi[],
{
- loadAccounts: async () => {
+ loadIntegrationAccounts: async () => {
const response = await externalDataSourcesOauthAccountsRetrieve(
String(ApiConfig.getCurrentProjectId()),
{
@@ -94,8 +94,8 @@ export const integrationAccountsLogic = kea<integrationAccountsLogicType>([
accountsLoaded: [
false,
{
- loadAccountsSuccess: () => true,
- loadAccountsFailure: () => true,
+ loadIntegrationAccountsSuccess: () => true,
+ loadIntegrationAccountsFailure: () => true,
},
],
// Surface the backend's actionable 400 message (e.g. "reconnect the integration") instead of
@@ -103,9 +103,9 @@ export const integrationAccountsLogic = kea<integrationAccountsLogicType>([
accountsError: [
null as string | null,
{
- loadAccounts: () => null,
- loadAccountsSuccess: () => null,
- loadAccountsFailure: (_, { error, errorObject }) =>
+ loadIntegrationAccounts: () => null,
+ loadIntegrationAccountsSuccess: () => null,
+ loadIntegrationAccountsFailure: (_, { error, errorObject }) =>
errorObject?.data?.detail ?? errorObject?.detail ?? error ?? null,
},
],
@@ -115,7 +115,7 @@ export const integrationAccountsLogic = kea<integrationAccountsLogicType>([
setSearch: async (_, breakpoint) => {
// Debounce keystrokes into a single server-side query.
await breakpoint(SEARCH_DEBOUNCE_MS)
- actions.loadAccounts()
+ actions.loadIntegrationAccounts()
},
})),
])
diff --git a/products/data_warehouse/frontend/shared/components/forms/IntegrationAccountSelector.tsx b/products/data_warehouse/frontend/shared/components/forms/IntegrationAccountSelector.tsx
index 558e96be26b2..7a873e63068f 100644
--- a/products/data_warehouse/frontend/shared/components/forms/IntegrationAccountSelector.tsx
+++ b/products/data_warehouse/frontend/shared/components/forms/IntegrationAccountSelector.tsx
@@ -362,11 +362,13 @@ function MultiAccountFieldWithOptions({
const { accounts, accountsLoading, accountsError } = useValues(
integrationAccountsLogic({ id: integrationId, sourceType })
)
- const { loadAccounts, setSearch } = useActions(integrationAccountsLogic({ id: integrationId, sourceType }))
+ const { loadIntegrationAccounts, setSearch } = useActions(
+ integrationAccountsLogic({ id: integrationId, sourceType })
+ )
useEffect(() => {
- loadAccounts()
- }, [loadAccounts])
+ loadIntegrationAccounts()
+ }, [loadIntegrationAccounts])
const options = useMemo<LemonInputSelectOption[]>(() => {
const sorted = [...accounts].sort((a, b) => Number(b.is_primary) - Number(a.is_primary))
@@ -463,11 +465,13 @@ function IntegrationAccountFieldWithDropdown({
const { accounts, accountsLoading, accountsLoaded, accountsError, search } = useValues(
integrationAccountsLogic({ id: integrationId, sourceType })
)
- const { loadAccounts, setSearch } = useActions(integrationAccountsLogic({ id: integrationId, sourceType }))
+ const { loadIntegrationAccounts, setSearch } = useActions(
+ integrationAccountsLogic({ id: integrationId, sourceType })
+ )
useEffect(() => {
- loadAccounts()
- }, [loadAccounts])
+ loadIntegrationAccounts()
+ }, [loadIntegrationAccounts])
// The list is filtered server-side, so while a search term is active `accounts` holds the
// matches rather than everything the connection can reach. Every "we found nothing" hint below