Skip to content

feat: add tag and value in validation error details #1760

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 5 commits into from
May 27, 2022

Conversation

AbhineetJain
Copy link
Contributor

This PR adds a more details to validation errors from the API.

Subtasks

  • update the error details to include value and tag
  • update test

Fixes #1757

@AbhineetJain AbhineetJain requested a review from Emyrk May 25, 2022 20:21
@AbhineetJain
Copy link
Contributor Author

@Emyrk Would this change impact our frontend behavior? Like here: https://github.com/coder/coder/blob/main/site/src/api/errors.ts#L41

@AbhineetJain
Copy link
Contributor Author

New behavior is as follows:

status code 400: Validation failed                         
        name: Validation failed for tag "username" with value: "-t"
status code 400: Validation failed                       
        name: Validation failed for tag "username" with value: ""

@@ -58,7 +58,7 @@ func TestRead(t *testing.T) {

var validate toValidate
require.True(t, httpapi.Read(rw, r, &validate))
require.Equal(t, validate.Value, "hi")
require.Equal(t, "hi", validate.Value)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The expected and actual arguments were inverted so I changed them to what they should be.

Copy link
Member

@Emyrk Emyrk left a comment

Choose a reason for hiding this comment

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

LG 👍

@AbhineetJain AbhineetJain marked this pull request as ready for review May 26, 2022 15:20
@Emyrk
Copy link
Member

Emyrk commented May 27, 2022

@Emyrk Would this change impact our frontend behavior? Like here: https://github.com/coder/coder/blob/main/site/src/api/errors.ts#L41

Yes it affects the FE, but I think it is still a positive change. Even for the FE

@AbhineetJain AbhineetJain merged commit 9929189 into main May 27, 2022
@AbhineetJain AbhineetJain deleted the abhineetjain/improve-validation-error branch May 27, 2022 14:13
kylecarbs pushed a commit that referenced this pull request Jun 10, 2022
* add tag and value in validation error details

* fix unit tests and linter

* add quotes around value

* fix unit tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Add more details to validation errors
2 participants