Skip to content
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

fix(data-warehouse): Added an error message for empty data source files #21843

Merged
merged 16 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/src/lib/components/DatabaseTableTree/TreeRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface TreeRowProps {
export function TreeRow({ item, onClick, selected }: TreeRowProps): JSX.Element {
const _onClick = useCallback(() => {
onClick && onClick(item.table)
}, [])
}, [onClick, item])

return (
<li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ import { dataWarehouseTableLogic } from './dataWarehouseTableLogic'

export function DatawarehouseTableForm(): JSX.Element {
return (
<Form formKey="table" logic={dataWarehouseTableLogic} className="space-y-4" enableFormOnSubmit>
<Form
formKey="table"
logic={dataWarehouseTableLogic}
className="space-y-4"
enableFormOnSubmit
autoComplete="off"
>
<div className="flex flex-col gap-2 max-w-160">
<LemonField name="name" label="Table Name">
<LemonInput
data-attr="table-name"
className="ph-ignore-input"
autoFocus
placeholder="Examples: stripe_invoice, hubspot_contacts, users"
autoComplete="off"
autoCapitalize="off"
Expand All @@ -25,7 +30,6 @@ export function DatawarehouseTableForm(): JSX.Element {
<LemonInput
data-attr="table-name"
className="ph-ignore-input"
autoFocus
placeholder="eg: https://your-org.s3.amazonaws.com/airbyte/stripe/invoices/*.pqt"
autoComplete="off"
autoCapitalize="off"
Expand All @@ -50,7 +54,6 @@ export function DatawarehouseTableForm(): JSX.Element {
<LemonInput
data-attr="access-key"
className="ph-ignore-input"
autoFocus
placeholder="eg: AKIAIOSFODNN7EXAMPLE"
autoComplete="off"
autoCapitalize="off"
Expand All @@ -62,7 +65,6 @@ export function DatawarehouseTableForm(): JSX.Element {
<LemonInput
data-attr="access-secret"
className="ph-ignore-input"
autoFocus
type="password"
placeholder="eg: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
autoComplete="off"
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/scenes/data-warehouse/new/NewSourceWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import PostgresSchemaForm from '../external/forms/PostgresSchemaForm'
import SourceForm from '../external/forms/SourceForm'
import { SyncProgressStep } from '../external/forms/SyncProgressStep'
import { DatawarehouseTableForm } from '../new/DataWarehouseTableForm'
import { dataWarehouseTableLogic } from './dataWarehouseTableLogic'
import { sourceWizardLogic } from './sourceWizardLogic'

export const scene: SceneExport = {
Expand All @@ -27,6 +28,7 @@ export function NewSourceWizard(): JSX.Element {
const { onBack, onSubmit, closeWizard } = useActions(sourceWizardLogic)
const { currentStep, isLoading, canGoBack, canGoNext, nextButtonText, showSkipButton } =
useValues(sourceWizardLogic)
const { tableLoading: manualLinkIsLoading } = useValues(dataWarehouseTableLogic)

const footer = useCallback(() => {
if (currentStep === 1) {
Expand All @@ -50,7 +52,7 @@ export function NewSourceWizard(): JSX.Element {
</LemonButton>
)}
<LemonButton
loading={isLoading}
loading={isLoading || manualLinkIsLoading}
disabledReason={!canGoNext && 'You cant click next yet'}
type="primary"
center
Expand All @@ -61,7 +63,7 @@ export function NewSourceWizard(): JSX.Element {
</LemonButton>
</div>
)
}, [currentStep, isLoading, canGoNext, canGoBack, nextButtonText, showSkipButton])
}, [currentStep, isLoading, manualLinkIsLoading, canGoNext, canGoBack, nextButtonText, showSkipButton])

return (
<>
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/scenes/data-warehouse/new/sourceWizardLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ export const sourceWizardLogic = kea<sourceWizardLogicType>([
],
}),
selectors({
isManualLinkingSelected: [(s) => [s.selectedConnector], (selectedConnector): boolean => !selectedConnector],
canGoBack: [
(s) => [s.currentStep],
(currentStep): boolean => {
Expand All @@ -274,8 +275,12 @@ export const sourceWizardLogic = kea<sourceWizardLogicType>([
},
],
nextButtonText: [
(s) => [s.currentStep],
(currentStep): string => {
(s) => [s.currentStep, s.isManualLinkingSelected],
(currentStep, isManualLinkingSelected): string => {
if (currentStep === 2 && isManualLinkingSelected) {
return 'Link'
}

if (currentStep === 3) {
return 'Import'
}
Expand Down
11 changes: 11 additions & 0 deletions posthog/warehouse/models/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@

ExtractErrors = {
"The AWS Access Key Id you provided does not exist": "The Access Key you provided does not exist",
"Access Denied: while reading key:": "Access was denied when reading the provided file",
"Could not list objects in bucket": "Access was denied to the provided bucket",
"file is empty": "The provided file contains no data",
"The specified key does not exist": "The provided file doesn't exist in the bucket",
"Cannot extract table structure from CSV format file, because there are no files with provided path in S3 or all files are empty": "The provided file doesn't exist in the bucket",
"Cannot extract table structure from Parquet format file, because there are no files with provided path in S3 or all files are empty": "The provided file doesn't exist in the bucket",
"Cannot extract table structure from JSONEachRow format file, because there are no files with provided path in S3 or all files are empty": "The provided file doesn't exist in the bucket",
"Bucket or key name are invalid in S3 URI": "The provided file or bucket doesn't exist",
"S3 exception: `NoSuchBucket`, message: 'The specified bucket does not exist.'": "The provided bucket doesn't exist",
"Either the file is corrupted or this is not a parquet file": "The provided file is not in Parquet format",
"Rows have different amount of values": "The provided file has rows with different amount of values",
}


Expand Down
Loading