Skip to content

Commit

Permalink
improve invalid space name error text (#945)
Browse files Browse the repository at this point in the history
  • Loading branch information
alfred-landrum authored Jun 26, 2020
1 parent 6d8ca05 commit ac2ea5e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions zqd/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,13 @@ func TestSpaceInvalidName(t *testing.T) {
_, err := client.SpacePost(ctx, api.SpacePostRequest{Name: "𝚭𝚴𝚪 is.good"})
require.NoError(t, err)
_, err = client.SpacePost(ctx, api.SpacePostRequest{Name: "𝚭𝚴𝚪/bad"})
require.EqualError(t, err, "status code 400: invalid space name")
require.EqualError(t, err, "status code 400: name may not contain '/' or non-printable characters")
})
t.Run("Put", func(t *testing.T) {
sp, err := client.SpacePost(ctx, api.SpacePostRequest{Name: "𝚭𝚴𝚪1"})
require.NoError(t, err)
err = client.SpacePut(ctx, sp.ID, api.SpacePutRequest{Name: "𝚭𝚴𝚪/2"})
require.EqualError(t, err, "status code 400: invalid space name")
require.EqualError(t, err, "status code 400: name may not contain '/' or non-printable characters")
})
}

Expand Down
2 changes: 1 addition & 1 deletion zqd/space/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func validateName(names map[string]api.SpaceID, name string) error {
return zqe.E(zqe.Invalid, "cannot set name to an empty string")
}
if !validSpaceName(name) {
return zqe.E(zqe.Invalid, "invalid space name")
return zqe.E(zqe.Invalid, "name may not contain '/' or non-printable characters")
}
if _, ok := names[name]; ok {
return zqe.E(zqe.Conflict, "space with name '%s' already exists", name)
Expand Down

0 comments on commit ac2ea5e

Please sign in to comment.