Skip to content

fix: do not skip parameter validation if min or max = 0 #7707

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 6 commits into from
May 30, 2023

Conversation

mtojek
Copy link
Member

@mtojek mtojek commented May 29, 2023

Related: #7582

This PR fixes the validation issue which enforced defining min and max together for a coder_parameter. Once this is merged, mix and max will be optional and not bound together.

@mtojek mtojek self-assigned this May 29, 2023
@mtojek
Copy link
Member Author

mtojek commented May 29, 2023

Run make --output-sync -j -B gen
fatal: No names found, cannot describe anything.
provisionersdk/proto/provisioner.proto: is a proto3 file that contains optional fields, but code generator protoc-gen-go-drpc hasn't been updated to support optional fields in proto3. Please ask the owner of this code generator to support proto3 optional.--go-drpc_out: 
make: *** [Makefile:48[6](https://github.com/coder/coder/actions/runs/5113424432/jobs/9192616072?pr=7707#step:16:7): provisionersdk/proto/provisioner.pb.go] Error 1
make: *** Waiting for unfinished jobs....

Does it look like we need to update the dependency on protoc-gen-go-grpc?

@mtojek mtojek requested review from spikecurtis and mafredri May 30, 2023 12:17
@mtojek mtojek marked this pull request as ready for review May 30, 2023 12:17
Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

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

Except for the potentially lossy migration, looks good! 👍🏻

BEGIN;
ALTER TABLE template_version_parameters ALTER COLUMN validation_min DROP NOT NULL;
ALTER TABLE template_version_parameters ALTER COLUMN validation_max DROP NOT NULL;
UPDATE template_version_parameters SET validation_min = NULL WHERE validation_min = 0;
Copy link
Member

Choose a reason for hiding this comment

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

Thinking out loud, what if someone has explicitly specified min to be 0 so that -1 can't be used? This seems like a potentially lossy migration and we should probably wait until templates are updated to receive their new, null value?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not worse than what we have today, because we treat min=0 as disabling validation!

Copy link
Member

Choose a reason for hiding this comment

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

Oh, didn't realize. That's both surprising and worrying, glad it's getting fixed. 😄

@@ -0,0 +1,6 @@
BEGIN;
UPDATE template_version_parameters SET validation_min = 0 WHERE validation_min = NULL;
UPDATE template_version_parameters SET validation_max = 0 WHERE validation_max = NULL;
Copy link
Member

Choose a reason for hiding this comment

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

On the other hand, the lossyness here seems fine.

@mtojek mtojek merged commit 702c908 into coder:main May 30, 2023
@github-actions github-actions bot locked and limited conversation to collaborators May 30, 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.

3 participants