Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"maxRuns": "Max Active Runs",
"missingAndErroredRuns": "Missing and Errored Runs",
"missingRuns": "Missing Runs",
"permissionDenied": "Dry Run Failed: User does not have permission to create backfills.",
"reprocessBehavior": "Reprocess Behavior",
"run": "Run Backfill",
"selectDescription": "Run this Dag for a range of dates",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ import { useTogglePause } from "src/queries/useTogglePause";

import ConfigForm from "../ConfigForm";
import { DateTimeInput } from "../DateTimeInput";
import { ErrorAlert } from "../ErrorAlert";
import { ErrorAlert, type ExpandedApiError } from "../ErrorAlert";
import type { DagRunTriggerParams } from "../TriggerDag/TriggerDAGForm";
import { Alert } from "../ui";
import { Checkbox } from "../ui/Checkbox";
import { getInlineMessage } from "./inlineMessage";

Expand Down Expand Up @@ -68,7 +69,11 @@ const RunBackfillForm = ({ dag, onClose }: RunBackfillFormProps) => {
const values = useWatch<BackfillFormProps>({
control,
});
const { data, isPending: isPendingDryRun } = useCreateBackfillDryRun({
const {
data,
error: dryRunError,
isPending: isPendingDryRun,
} = useCreateBackfillDryRun({
requestBody: {
requestBody: {
dag_id: dag.dag_id,
Expand Down Expand Up @@ -123,13 +128,23 @@ const RunBackfillForm = ({ dag, onClose }: RunBackfillFormProps) => {
reset(fdata);
onClose();
};

const resetDateError = () => setErrors((prev) => ({ ...prev, date: undefined }));
const affectedTasks = data ?? { backfills: [], total_entries: 0 };

// Check if the dry run error is a permission error (403)
const isPermissionError =
dryRunError !== undefined && dryRunError !== null && (dryRunError as ExpandedApiError).status === 403;

const inlineMessage = getInlineMessage(isPendingDryRun, affectedTasks.total_entries, translate);

return (
<>
<ErrorAlert error={errors.date ?? error} />
{isPermissionError ? (
<Alert status="error">{translate("backfill.permissionDenied")}</Alert>
) : (
<ErrorAlert error={errors.date ?? dryRunError ?? error} />
)}
<VStack alignItems="stretch" gap={2} pt={4}>
<Box>
<Text fontSize="md" fontWeight="semibold" mb={3}>
Expand Down Expand Up @@ -159,7 +174,7 @@ const RunBackfillForm = ({ dag, onClose }: RunBackfillFormProps) => {
/>
</HStack>
</Box>
{noDataInterval || dataIntervalInvalid ? undefined : <Box>{inlineMessage}</Box>}
{noDataInterval || dataIntervalInvalid || isPermissionError ? undefined : <Box>{inlineMessage}</Box>}
<Spacer />
<Controller
control={control}
Expand Down
Loading