Skip to content

Commit df6f791

Browse files
fix(ui/ingestion): bug fixes in the new ingestion flow (#15786)
Co-authored-by: Chris Collins <chriscollins3456@gmail.com>
1 parent 68274db commit df6f791

File tree

6 files changed

+36
-18
lines changed

6 files changed

+36
-18
lines changed

datahub-web-react/src/app/ingestV2/source/builder/RecipeForm/TestConnection/TestConnectionButton.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,18 @@ import {
1818
} from '@graphql/ingestion.generated';
1919
import { ExecutionRequestResult, IngestionSource } from '@types';
2020

21-
export function getRecipeJson(recipeYaml: string) {
21+
export function getRecipeJson(recipeYaml: string, hideWarnings?: boolean) {
2222
// Convert the recipe into it's json representation, and catch + report exceptions while we do it.
2323
let recipeJson;
2424
try {
2525
recipeJson = yamlToJson(recipeYaml);
2626
} catch (e) {
27-
const messageText = (e as any).parsedLine
28-
? `Please fix line ${(e as any).parsedLine} in your recipe.`
29-
: 'Please check your recipe configuration.';
30-
message.warn(`Found invalid YAML. ${messageText}`);
27+
if (!hideWarnings) {
28+
const messageText = (e as any).parsedLine
29+
? `Please fix line ${(e as any).parsedLine} in your recipe.`
30+
: 'Please check your recipe configuration.';
31+
message.warn(`Found invalid YAML. ${messageText}`);
32+
}
3133
return null;
3234
}
3335
return recipeJson;

datahub-web-react/src/app/ingestV2/source/builder/sources.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@
315315
"displayName": "Vertica",
316316
"description": "Import Databases, Schemas, Tables, Views, Projections, statistics, and lineage from Vertica.",
317317
"docsUrl": "https://docs.datahub.com/docs/generated/ingestion/sources/vertica/",
318-
"recipe": "source:\n type: vertica\n config:\n # Coordinates\n host_port: localhost:5433\n # The name of the vertica database\n database: Database_Name\n # Credentials\n username: Vertica_User\n password: Vertica_Password\n\n include_tables: true\n include_views: true\n include_projections: true\n include_models: true\n include_view_lineage: true\n include_projection_lineage: true\n profiling:\n enabled: false\n stateful_ingestion:\n enabled: true ",
318+
"recipe": "source:\n type: vertica\n config:\n # Coordinates\n host_port: # localhost:5433\n # The name of the vertica database\n database: # Database_Name\n # Credentials\n username: # Vertica_User\n password: # Vertica_Password\n\n include_tables: true\n include_views: true\n include_projections: true\n include_models: true\n include_view_lineage: true\n include_projection_lineage: true\n profiling:\n enabled: false\n stateful_ingestion:\n enabled: true ",
319319
"category": "Data Warehouse",
320320
"isPopular": false
321321
},

datahub-web-react/src/app/ingestV2/source/multiStepBuilder/IngestionSourceUpdatePage.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,10 @@ export function IngestionSourceUpdatePage() {
150150
sourceType: ingestionSourceData?.ingestionSource?.type,
151151
exitType: 'cancel',
152152
});
153-
history.push(ingestionSourcesListBackUrl ?? PageRoutes.INGESTION);
154-
}, [history, ingestionSourceData?.ingestionSource?.type, ingestionSourcesListBackUrl]);
153+
history.push(ingestionSourcesListBackUrl ?? PageRoutes.INGESTION, {
154+
createdOrUpdatedSourceUrn: urn,
155+
});
156+
}, [history, ingestionSourceData?.ingestionSource?.type, ingestionSourcesListBackUrl, urn]);
155157

156158
const isDirtyChecker = useCallback(
157159
(

datahub-web-react/src/app/ingestV2/source/multiStepBuilder/steps/step2ConnectionDetails/ConnectionDetailsStep.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { LookerWarning } from '@app/ingestV2/source/builder/LookerWarning';
99
import { getRecipeJson } from '@app/ingestV2/source/builder/RecipeForm/TestConnection/TestConnectionButton';
1010
import { CSV, LOOKER, LOOK_ML } from '@app/ingestV2/source/builder/constants';
1111
import { useIngestionSources } from '@app/ingestV2/source/builder/useIngestionSources';
12+
import { INGESTION_TYPE_ERROR } from '@app/ingestV2/source/multiStepBuilder/steps/step2ConnectionDetails/constants';
1213
import { AdvancedSection } from '@app/ingestV2/source/multiStepBuilder/steps/step2ConnectionDetails/sections/AdvansedSection';
1314
import { NameAndOwnersSection } from '@app/ingestV2/source/multiStepBuilder/steps/step2ConnectionDetails/sections/NameAndOwnersSection';
1415
import { RecipeSection } from '@app/ingestV2/source/multiStepBuilder/steps/step2ConnectionDetails/sections/recipeSection/RecipeSection';
@@ -41,12 +42,14 @@ export function ConnectionDetailsStep() {
4142
const [stagedRecipeYml, setStagedRecipeYml] = useState(initialRecipeYml || placeholderRecipe);
4243

4344
const updateRecipe = useCallback(
44-
(recipe: string, shouldSetIsRecipeValid?: boolean) => {
45-
const recipeJson = getRecipeJson(recipe);
46-
if (!recipeJson) return;
45+
(recipe: string, shouldSetIsRecipeValid?: boolean, hideYamlWarnings = false) => {
46+
const recipeJson = getRecipeJson(recipe, hideYamlWarnings);
47+
if (!recipeJson) {
48+
throw Error('Invalid YAML');
49+
}
4750

4851
if (!JSON.parse(recipeJson).source?.type) {
49-
throw Error('Ingestion type is undefined');
52+
throw Error(INGESTION_TYPE_ERROR);
5053
}
5154

5255
const newState = {
@@ -67,7 +70,7 @@ export function ConnectionDetailsStep() {
6770
(recipe: string) => {
6871
setStagedRecipeYml(recipe);
6972
try {
70-
updateRecipe(recipe);
73+
updateRecipe(recipe, false, true);
7174
} catch (e: unknown) {
7275
if (e instanceof Error) {
7376
console.error(e.message);
@@ -120,11 +123,14 @@ export function ConnectionDetailsStep() {
120123
updateRecipe(stagedRecipeYml, true);
121124
} catch (e: unknown) {
122125
if (e instanceof Error) {
123-
message.warning({
124-
content: `Please add valid ingestion type`,
125-
duration: 3,
126-
});
126+
if (e.message === INGESTION_TYPE_ERROR) {
127+
message.warning({
128+
content: `Please add valid ingestion type`,
129+
duration: 3,
130+
});
131+
}
127132
}
133+
throw e;
128134
}
129135
}, [stagedRecipeYml, updateRecipe]);
130136

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
export const MAX_FORM_WIDTH = '524px';
2+
3+
export const INGESTION_TYPE_ERROR = 'INGESTION_TYPE_ERROR';

datahub-web-react/src/app/ingestV2/source/multiStepBuilder/steps/step2ConnectionDetails/sections/recipeSection/recipeForm/fields/SelectField.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@ export function SelectField({ field, updateFormValue }: CommonFieldProps) {
99
const form = Form.useFormInstance();
1010
const value = Form.useWatch([field.name], form);
1111

12+
const handleUpdate = (values?: string[]) => {
13+
const selectedValue = values?.[0];
14+
form.setFieldsValue({ [field.name]: selectedValue });
15+
updateFormValue(field.name, selectedValue);
16+
};
17+
1218
return (
1319
<RecipeFormItem recipeField={field} showHelperText>
1420
<SimpleSelect
1521
values={value ? [value] : []}
16-
onUpdate={(values) => updateFormValue(field.name, values?.[0])}
22+
onUpdate={handleUpdate}
1723
placeholder={field.placeholder}
1824
options={field.options ?? []}
1925
showClear={!field.required}

0 commit comments

Comments
 (0)