Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4095330

Browse files
fix: use only template version ID to create task workspace (#18642)
When creating a new task, the following error was getting returned: **Error:** ```json { "message": "Validation failed.", "validations": [ { "field": "template_id", "detail": "Validation failed for tag \"excluded_with\" with value: \"42205a38-845c-4186-8475-f002e0936d53\"" }, { "field": "template_version_id", "detail": "Validation failed for tag \"excluded_with\" with value: \"22b1c4b7-432d-4eb5-9341-cd8efacb8f46\"" } ] } ``` Caused by #18623
1 parent d4208d2 commit 4095330

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

site/src/pages/TasksPage/TasksPage.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ const TaskFormSection: FC<{
206206
);
207207
};
208208

209-
type CreateTaskMutationFnProps = { prompt: string; template: Template };
209+
type CreateTaskMutationFnProps = { prompt: string; templateVersionId: string };
210210

211211
type TaskFormProps = {
212212
templates: Template[];
@@ -236,8 +236,11 @@ const TaskForm: FC<TaskFormProps> = ({ templates, onSuccess }) => {
236236
: true;
237237

238238
const createTaskMutation = useMutation({
239-
mutationFn: async ({ prompt, template }: CreateTaskMutationFnProps) =>
240-
data.createTask(prompt, user.id, template.id, template.active_version_id),
239+
mutationFn: async ({
240+
prompt,
241+
templateVersionId,
242+
}: CreateTaskMutationFnProps) =>
243+
data.createTask(prompt, user.id, templateVersionId),
241244
onSuccess: async (task) => {
242245
await queryClient.invalidateQueries({
243246
queryKey: ["tasks"],
@@ -257,7 +260,7 @@ const TaskForm: FC<TaskFormProps> = ({ templates, onSuccess }) => {
257260
try {
258261
await createTaskMutation.mutateAsync({
259262
prompt,
260-
template: selectedTemplate,
263+
templateVersionId: selectedTemplate.active_version_id,
261264
});
262265
} catch (error) {
263266
const message = getErrorMessage(error, "Error creating task");
@@ -600,14 +603,12 @@ export const data = {
600603
async createTask(
601604
prompt: string,
602605
userId: string,
603-
templateId: string,
604606
templateVersionId: string,
605607
): Promise<Task> {
606608
const presets = await API.getTemplateVersionPresets(templateVersionId);
607609
const defaultPreset = presets.find((p) => p.Default);
608610
const workspace = await API.createWorkspace(userId, {
609611
name: `task-${generateWorkspaceName()}`,
610-
template_id: templateId,
611612
template_version_id: templateVersionId,
612613
template_version_preset_id: defaultPreset?.ID,
613614
rich_parameter_values: [

0 commit comments

Comments
 (0)