Repository navigation
fix(site): allow editing parameters when the template forces an update - #29795
Open
blinkagent[bot] wants to merge 1 commit into
Open
blinkagent[bot] wants to merge 1 commit into
blinkagent[bot] wants to merge 1 commit into
Conversation
When a template has require_active_version enabled and the workspace is outdated, the parameters form was fully disabled for anyone without template update permission. Members could therefore never edit any parameter, including ones the new version did not change, which left them unable to start their workspace if a new version introduced a validation their current values did not satisfy. Such a user can only ever build against the active version, so evaluate and submit parameters against it instead of disabling the form.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #19676
Problem
When a template has
require_active_versionenabled and the workspace is outdated, the workspace parameters form was disabled in its entirety for any user without template update permission, which in practice means everyMember.canChangeVersionsispermissions.updateWorkspaceVersion, an authz check foraction: "update"on the template, so only template admins and owners satisfy it.disabledwas then OR'd into theisDisabledof every field and into the submit button, so even parameters the new template version did not touch were locked.The result is a deadlock. If a new version adds a validation the workspace's current parameter values do not satisfy, the forced update fails, the user is sent to the parameters page to fix the values, and the form is read-only. The user cannot start their workspace at all. This reproduces on both entry paths: clicking "Update and restart" first, and going to the parameters page first.
Fix
A user who cannot pin versions can only ever submit a build against the active version, so there is nothing to protect against by locking the form. Instead of disabling it, the page now evaluates and submits parameters against
workspace.template_active_version_idwheneverrequire_active_versionis set and the user lacks the permission.WorkspaceParametersPage.tsxderives the target version from the active version in that case, which drives both the dynamic parameters websocket and thetemplate_version_idon the resulting build.WorkspaceParametersPageView.tsxdrops the blanketdisabledflag. Immutable parameters,styling.disabledparameters, and the in-flight submit state still disable fields exactly as before.Behaviour for users who can change versions is unchanged.
Tests
WorkspaceParametersPage.test.tsx: a user withoutupdateWorkspaceVersionon an outdatedrequire_active_versionworkspace gets an editable form, an enabled submit button, and parameters evaluated against the active version. Immutable parameters stay disabled. Verified that it fails without the source change.RequireActiveVersion*stories to assert the form is now usable.pnpm run check,pnpm run format:check,pnpm run lint:oxlint,tsc --noEmit, and both the unit and storybook test runs for this page pass locally.