Skip to content

Commit eade5b0

Browse files
authored
fix: handle null response from the template presets endpoint (#18723)
The template presets endpoint returns a null response when a template version does not define any presets.
1 parent 33bbf18 commit eade5b0

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

site/src/api/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,7 @@ class ApiMethods {
12371237

12381238
getTemplateVersionPresets = async (
12391239
templateVersionId: string,
1240-
): Promise<TypesGen.Preset[]> => {
1240+
): Promise<TypesGen.Preset[] | null> => {
12411241
const response = await this.axios.get<TypesGen.Preset[]>(
12421242
`/api/v2/templateversions/${templateVersionId}/presets`,
12431243
);

site/src/pages/TasksPage/TasksPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ export const data = {
610610
templateVersionId: string,
611611
): Promise<Task> {
612612
const presets = await API.getTemplateVersionPresets(templateVersionId);
613-
const defaultPreset = presets.find((p) => p.Default);
613+
const defaultPreset = presets?.find((p) => p.Default);
614614
const workspace = await API.createWorkspace(userId, {
615615
name: `task-${generateWorkspaceName()}`,
616616
template_version_id: templateVersionId,

0 commit comments

Comments
 (0)