Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Workspace settings doesn't validate monotonic parameters before submit #20978

Open
Labels
bugparametersbugs & feature requests related to Dynamic Parameters
@blinkagent

Description

@blinkagent

Problem

When updating workspace parameters in the Workspace Settings page, monotonic validation (forvalidation_monotonic = "increasing" or"decreasing") is not enforced in the UI. Users can enter values that violate monotonic constraints, and the error only appears after clicking "Submit and restart" and the backend rejects it.

Root Cause

TheWorkspaceParametersForm component does not pass thelastBuildParameters to the validation schema:

https://github.com/coder/coder/blob/main/site/src/pages/WorkspaceSettingsPage/WorkspaceParametersPage/WorkspaceParametersForm.tsx#L60-L66

validationSchema:Yup.object({rich_parameter_values:useValidationSchemaForRichParameters(templateVersionRichParameters,// Missing second argument: lastBuildParameters),}),

TheuseValidationSchemaForRichParameters function signature accepts a second parameter for previous values:

https://github.com/coder/coder/blob/main/site/src/utils/richParameters.ts#L56-L58

exportconstuseValidationSchemaForRichParameters=(templateParameters?:TemplateVersionParameter[],lastBuildParameters?:WorkspaceBuildParameter[],// Not being passed!):Yup.AnySchema=>{

WithoutlastBuildParameters, the monotonic validation logic at lines 120-147 never runs.

Expected Behavior

For a parameter defined as:

data"coder_parameter""custom_value" {name="custom_value"display_name="Custom Value"default="1000"type="number"mutable=truevalidation {monotonic="increasing"min=500max=2000  }}

If the previous build hadcustom_value = 1500, the UI should:

  1. Show a validation error if the user enters a value less than 1500
  2. Display: "Value must only ever increase (last value was 1500)"
  3. Prevent form submission until a valid value is entered

Actual Behavior

The UI allows any value between 500-2000 to be entered. The error only appears after submitting when the backend/Terraform provider rejects it.

Solution

PassautofillParams (which contains the previous build parameters) as the second argument:

validationSchema:Yup.object({rich_parameter_values:useValidationSchemaForRichParameters(templateVersionRichParameters,autofillParams,// Add this!),}),

This will enable the frontend Yup validation to check monotonic constraints before submission.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugparametersbugs & feature requests related to Dynamic Parameters

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp