Skip to content

Commit

Permalink
Fix status check on JobItem and ensure that SourceService returns…
Browse files Browse the repository at this point in the history
… `LogsRequestError` when there are logs.
  • Loading branch information
edmundito committed Aug 16, 2022
1 parent 7b83718 commit 756b7c1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
26 changes: 14 additions & 12 deletions airbyte-webapp/src/components/JobItem/JobItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,23 @@ interface JobItemProps {
job: SynchronousJobReadWithStatus | JobsWithJobs;
}

const didJobSucceed = (job: SynchronousJobReadWithStatus | JobsWithJobs) => {
return getJobStatus(job) !== "failed";
};
const didJobSucceed = (job: SynchronousJobReadWithStatus | JobsWithJobs): boolean =>
"succeeded" in job ? job.succeeded : getJobStatus(job) !== "failed";

export const getJobStatus: (
job: SynchronousJobReadWithStatus | JobsWithJobs
) => JobStatus | CheckConnectionReadStatus = (job) => {
return "status" in job ? job.status : job.job.status;
};

export const getJobAttemps: (job: SynchronousJobReadWithStatus | JobsWithJobs) => AttemptRead[] | undefined = (job) => {
return "attempts" in job ? job.attempts : undefined;
};

export const getJobId = (job: SynchronousJobReadWithStatus | JobsWithJobs) => ("id" in job ? job.id : job.job.id);
) => JobStatus | CheckConnectionReadStatus = (job) =>
"succeeded" in job
? job.succeeded
? CheckConnectionReadStatus.succeeded
: CheckConnectionReadStatus.failed
: job.job.status;

export const getJobAttemps: (job: SynchronousJobReadWithStatus | JobsWithJobs) => AttemptRead[] | undefined = (job) =>
"attempts" in job ? job.attempts : undefined;

export const getJobId = (job: SynchronousJobReadWithStatus | JobsWithJobs): string | number =>
"id" in job ? job.id : job.job.id;

export const JobItem: React.FC<JobItemProps> = ({ job }) => {
const { jobId: linkedJobId } = useAttemptLink();
Expand Down
2 changes: 1 addition & 1 deletion airbyte-webapp/src/core/domain/connector/SourceService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class SourceService extends AirbyteRequestService {

if (!result.jobInfo?.succeeded || !result.catalog) {
// @ts-expect-error TODO: address this case
const e = new CommonRequestError(result);
const e = result.jobInfo?.logs ? new LogsRequestError(result.jobInfo) : new CommonRequestError(result);
// Generate error with failed status and received logs
e._status = 400;
// @ts-expect-error address this case
Expand Down

0 comments on commit 756b7c1

Please sign in to comment.