Skip to content

fix: prompt when parameter options are incompatible #9247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Aug 23, 2023
Merged

Conversation

mtojek
Copy link
Member

@mtojek mtojek commented Aug 22, 2023

Related: #9163

This PR modifies CLI and site to prompt user for correct parameter options if they are incompatible now (new template version submitted).

@mtojek mtojek self-assigned this Aug 22, 2023
@@ -1243,6 +1242,35 @@ const getMissingParameters = (
missingParameters.push(parameter)
}

// Check if parameter "options" changed and we can't use old build parameters.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BrunoQuaresma I may need your frontend wisdom. I battling the following edge case here:

  1. We have a foobar string parameter with options: aaa, bbb (default), ccc, and the workspace built on it. The workspace uses bbb option.
  2. Change the parameter option bbb to something else, let's say ddd.
  3. Click "Update".

I can see the UpdateParametersDialog, but when I click the Update button, it gets back to it. If I pick something else, and then click back to the default, it works fine.

I looked deeper, and it seems that Formik doesn't set the internal form.values, even though initialValues are passed. I'm not sure how I can proceed here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently, I got it fixes with enableReinitialize. Thanks for the suggestion!

@mtojek mtojek changed the title fix: ask for changed parameter options fix: prompt when parameter options are incompatible Aug 23, 2023
@@ -981,6 +981,8 @@ func (p *prettyErrorFormatter) format(err error) {
msg = sdkError.Message
if sdkError.Helper != "" {
msg = msg + "\n" + sdkError.Helper
} else if sdkError.Detail != "" {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for reviewers:

Message: "Unable to validate parameter X"
Detail: "parameter value must match one of options"

^ this should be consistent with site UI error

@@ -69,7 +69,6 @@ const (
type JobErrorCode string

const (
MissingTemplateParameter JobErrorCode = "MISSING_TEMPLATE_PARAMETER"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for reviewers: used by old legacy parameters (do not exist anymore)

@@ -1243,6 +1242,35 @@ const getMissingParameters = (
missingParameters.push(parameter)
}

// Check if parameter "options" changed and we can't use old build parameters.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently, I got it fixes with enableReinitialize. Thanks for the suggestion!

@mtojek mtojek marked this pull request as ready for review August 23, 2023 12:57
<-doneChan
})

t.Run("ParameterOptionChanged", func(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test case where the chosen template parameter disappears completely?

e.g. before: { 1st, 2nd, 3rd }, after: { 1st, 3rd, 4th }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added!

@mtojek mtojek merged commit e845dea into main Aug 23, 2023
@mtojek mtojek deleted the 9163-cleanup-errors branch August 23, 2023 16:18
@github-actions github-actions bot locked and limited conversation to collaborators Aug 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants