mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
## Summary Fixes [FE-3987](https://linear.app/supabase/issue/FE-3987/contact-support-pre-fills-the-wrong-supabase-project-id): the "Contact support" button shown in the Table Editor's inline error banner (e.g. "Failed to retrieve rows from table") didn't pass the current project or organization to the support form. This caused the support form to fall back to the user's first organization/project instead of the one actually affected — especially noticeable when the Management API request used to resolve the org also fails. ## Test plan - [ ] Open a project in Studio, go to **Table Editor**, open a table. - [ ] Trigger a failing table query — either block the `rest/v1/<table>` request in DevTools, or apply a filter with a mismatched type (e.g. `id = 'abc'` on an int column). - [ ] On the inline red "Failed to retrieve rows from table" banner, click **Contact support**. - [ ] Confirm the support form pre-fills the **correct organization and project** — the one the failing table actually belongs to. - [ ] Repeat with a project belonging to an organization that is *not* first in your org list, to confirm it's not coincidentally correct. - [ ] Repeat while simulating a Management API failure (e.g. block `api.supabase.com`/`*.supabase.co/platform/*`) to confirm the org still resolves correctly via the `orgSlug` fallback instead of silently defaulting to your first org. - [ ] Sanity check other "Contact support" entry points (header Feedback dropdown, Help sidebar) are unaffected — they use a separate, already-correct code path. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved error handling when project details cannot be loaded, preserving relevant project and organization context. * Improved fallback behavior for identifying the correct organization when project information is unavailable or unresolved. * Support requests opened from error messages now include applicable project and organization information. * Error messages now consistently display available additional actions alongside contact support options. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
124 lines
3.0 KiB
TypeScript
124 lines
3.0 KiB
TypeScript
import { SupportCategories } from '@supabase/shared-types/out/constants'
|
|
import { PropsWithChildren, useEffect, useRef } from 'react'
|
|
import { Button } from 'ui'
|
|
import { Admonition } from 'ui-patterns/Admonition'
|
|
|
|
import { SupportLink } from '@/components/interfaces/Support/SupportLink'
|
|
import { isDashboardErrorSampled } from '@/lib/telemetry/error-sampling'
|
|
import { useTrack } from '@/lib/telemetry/track'
|
|
|
|
export interface AlertErrorProps {
|
|
projectRef?: string
|
|
orgSlug?: string
|
|
subject?: string
|
|
description?: string
|
|
error?: { message: string } | null
|
|
layout?: 'vertical' | 'horizontal' | 'responsive'
|
|
className?: string
|
|
showIcon?: boolean
|
|
showInstructions?: boolean
|
|
showErrorPrefix?: boolean
|
|
additionalActions?: React.ReactNode
|
|
hideContactSupport?: boolean
|
|
}
|
|
|
|
export const ContactSupportButton = ({
|
|
projectRef,
|
|
orgSlug,
|
|
subject,
|
|
error,
|
|
}: {
|
|
projectRef?: string
|
|
orgSlug?: string
|
|
subject?: string
|
|
error?: { message: string } | null
|
|
}) => {
|
|
return (
|
|
<Button asChild className="w-min">
|
|
<SupportLink
|
|
queryParams={{
|
|
category: SupportCategories.DASHBOARD_BUG,
|
|
projectRef,
|
|
orgSlug,
|
|
subject,
|
|
error: error?.message,
|
|
}}
|
|
>
|
|
Contact support
|
|
</SupportLink>
|
|
</Button>
|
|
)
|
|
}
|
|
|
|
// [Joshen] To standardize the language for all error UIs
|
|
export const AlertError = ({
|
|
projectRef,
|
|
orgSlug,
|
|
subject,
|
|
description = 'Try refreshing your browser, but if the issue persists for more than a few minutes, please reach out to us via support.',
|
|
error,
|
|
className,
|
|
showIcon = true,
|
|
layout = 'responsive',
|
|
showInstructions = true,
|
|
showErrorPrefix = true,
|
|
children,
|
|
additionalActions,
|
|
hideContactSupport = false,
|
|
}: PropsWithChildren<AlertErrorProps>) => {
|
|
const track = useTrack()
|
|
const hasTrackedRef = useRef(false)
|
|
|
|
const formattedErrorMessage = error?.message?.includes('503')
|
|
? '503 Service Temporarily Unavailable'
|
|
: error?.message
|
|
|
|
useEffect(() => {
|
|
if (!hasTrackedRef.current) {
|
|
hasTrackedRef.current = true
|
|
if (isDashboardErrorSampled()) {
|
|
track('dashboard_error_created', {
|
|
source: 'admonition',
|
|
})
|
|
}
|
|
}
|
|
}, [track])
|
|
|
|
return (
|
|
<Admonition
|
|
type="warning"
|
|
layout={additionalActions ? 'vertical' : layout}
|
|
showIcon={showIcon}
|
|
title={subject}
|
|
description={
|
|
<>
|
|
{error?.message && (
|
|
<p>
|
|
{showErrorPrefix && 'Error: '}
|
|
{formattedErrorMessage}
|
|
</p>
|
|
)}
|
|
{showInstructions && <p>{description}</p>}
|
|
{children}
|
|
</>
|
|
}
|
|
actions={
|
|
additionalActions || !hideContactSupport ? (
|
|
<>
|
|
{additionalActions}
|
|
{!hideContactSupport && (
|
|
<ContactSupportButton
|
|
projectRef={projectRef}
|
|
orgSlug={orgSlug}
|
|
subject={subject}
|
|
error={error}
|
|
/>
|
|
)}
|
|
</>
|
|
) : null
|
|
}
|
|
className={className}
|
|
/>
|
|
)
|
|
}
|