Skip to content

Commit

Permalink
🪟🐛 Connector builder: Prevent read request with wrong / missing strea…
Browse files Browse the repository at this point in the history
…m name (#5939)
  • Loading branch information
Joe Reuter committed Apr 18, 2023
1 parent f6db1b0 commit 9825e10
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ interface StreamTestButtonProps {
hasTestInputJsonErrors: boolean;
hasStreamListErrors: boolean;
setTestInputOpen: (open: boolean) => void;
isFetchingStreamList: boolean;
}

export const StreamTestButton: React.FC<StreamTestButtonProps> = ({
readStream,
hasTestInputJsonErrors,
hasStreamListErrors,
setTestInputOpen,
isFetchingStreamList,
}) => {
const { editorView, yamlIsValid } = useConnectorBuilderFormState();
const { hasErrors, validateAndTouch } = useBuilderErrors();
Expand All @@ -45,6 +47,11 @@ export const StreamTestButton: React.FC<StreamTestButtonProps> = ({
let showWarningIcon = false;
let tooltipContent = undefined;

if (isFetchingStreamList && editorView === "yaml") {
buttonDisabled = true;
tooltipContent = <FormattedMessage id="connectorBuilder.resolvingStreamList" />;
}

if (editorView === "yaml" && !yamlIsValid) {
buttonDisabled = true;
showWarningIcon = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export const StreamTester: React.FC<{
stream_name: streamName,
});
}}
isFetchingStreamList={isFetchingStreamList}
hasTestInputJsonErrors={hasTestInputJsonErrors}
hasStreamListErrors={Boolean(streamListErrorMessage)}
setTestInputOpen={setTestInputOpen}
Expand Down
1 change: 1 addition & 0 deletions airbyte-webapp/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,7 @@
"connectorBuilder.warnings.noRecords": "No records could be extracted from responses, make sure the record selector is set correctly.",
"connectorBuilder.warnings.primaryKeyMissing": "In at least one record, the configured primary key is not set. Make sure it is always available.",
"connectorBuilder.warnings.primaryKeyDuplicate": "Primary key is not unique - found <b>{duplicateKey}</b> more than once.",
"connectorBuilder.resolvingStreamList": "Checking configuration",

"jobs.noAttemptsFailure": "Failed to start job.",

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ function getSavingState(

export const ConnectorBuilderTestStateProvider: React.FC<React.PropsWithChildren<unknown>> = ({ children }) => {
const { formatMessage } = useIntl();
const { lastValidJsonManifest, selectedView, projectId } = useConnectorBuilderFormState();
const { lastValidJsonManifest, selectedView, projectId, editorView, builderFormValues } =
useConnectorBuilderFormState();

const manifest = lastValidJsonManifest ?? DEFAULT_JSON_MANIFEST_VALUES;

Expand Down Expand Up @@ -424,9 +425,12 @@ export const ConnectorBuilderTestStateProvider: React.FC<React.PropsWithChildren
}
}, [selectedView]);

const streamName =
editorView === "ui" ? builderFormValues.streams[testStreamIndex]?.name : streams[testStreamIndex]?.name;

const streamRead = useReadStream(projectId, {
manifest,
stream: streams[testStreamIndex]?.name,
stream: streamName,
config: testInputWithDefaults,
});

Expand Down

0 comments on commit 9825e10

Please sign in to comment.