Skip to content

Commit 6804353

Browse files
committed
lil cleanup
1 parent 31ed5ea commit 6804353

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

site/src/api/api.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ export class ParameterValidationError extends Error {
399399
super("Parameters are not valid for new template version");
400400
}
401401
}
402+
402403
export type GetProvisionerJobsParams = {
403404
status?: string;
404405
limit?: number;
@@ -2199,9 +2200,9 @@ class ApiMethods {
21992200
default_value: p.default_value?.valid ? p.default_value.value : "",
22002201
options: p.options
22012202
? p.options.map((opt) => ({
2202-
...opt,
2203-
value: opt.value?.valid ? opt.value.value : "",
2204-
}))
2203+
...opt,
2204+
value: opt.value?.valid ? opt.value.value : "",
2205+
}))
22052206
: [],
22062207
}));
22072208
};
@@ -2284,6 +2285,8 @@ class ApiMethods {
22842285
rich_parameter_values: newBuildParameters,
22852286
});
22862287
} catch (error) {
2288+
// If the build failed because of a parameter validation error, then we
2289+
// throw a special sentinel error that can be caught by the caller.
22872290
if (
22882291
isApiError(error) &&
22892292
error.response.status === 400 &&
@@ -2625,7 +2628,7 @@ class ApiMethods {
26252628
// All methods must be defined with arrow function syntax. See the docstring
26262629
// above the ApiMethods class for a full explanation.
26272630
class ExperimentalApiMethods {
2628-
constructor(protected readonly axios: AxiosInstance) {}
2631+
constructor(protected readonly axios: AxiosInstance) { }
26292632

26302633
getAITasksPrompts = async (
26312634
buildIds: TypesGen.WorkspaceBuild["id"][],

site/src/modules/workspaces/WorkspaceUpdateDialogs.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ const MissingBuildParametersDialog: FC<MissingBuildParametersDialogProps> = ({
157157
const missedParameters =
158158
error instanceof MissingBuildParameters ? error.parameters : [];
159159
const versionId =
160-
error instanceof MissingBuildParameters ? error.versionId : undefined;
160+
error instanceof ParameterValidationError ? error.versionId : undefined;
161161
const isOpen =
162162
error instanceof MissingBuildParameters ||
163163
error instanceof ParameterValidationError;
@@ -177,9 +177,7 @@ const MissingBuildParametersDialog: FC<MissingBuildParametersDialogProps> = ({
177177
onClose={dialogProps.onClose}
178178
workspaceOwnerName={workspace.owner_name}
179179
workspaceName={workspace.name}
180-
templateVersionId={
181-
error instanceof ParameterValidationError ? error.versionId : undefined
182-
}
180+
templateVersionId={versionId}
183181
/>
184182
);
185183
};

0 commit comments

Comments
 (0)