fix(user): don't reject an unspecified language on admin user creation - #21
Merged
Merged
Conversation
The docsales-admin create-user form (PR #14/#15) has no language field, so CreateUserBody.Language is always sent empty - and the shared "language" govalidator tag treated empty as invalid, rejecting every request from that form with a generic "invalid data" error. Treat an empty language as "not specified" (valid, left as-is) instead of a validation failure. Non-empty values are still checked against the registered translations exactly as before - this only affects callers that omit the field entirely, matching how user creation already behaves elsewhere (e.g. the CLI's `user create` command never sets a language either).
Preview DeploymentPreview deployments for this PR are available at:
The preview environment will start automatically on first visit. Subsequent pushes to this PR will update the Run locally with Dockerdocker pull ghcr.io/docsales/vikunja:pr-21
docker run -p 3456:3456 ghcr.io/docsales/vikunja:pr-21Last updated for commit d0adbc6 |
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.
Why
The
/usersadmin page's Create User form has no language field, so every request from it hits the sharedlanguagegovalidator tag with an empty string - which treated empty as invalid, failing the whole request with a generic "invalid data" error before it ever reached the create logic. Reproduced live just now trying to create an account for a new hire.What
The
languagetag now treats an empty string as "not specified" (valid) instead of a validation failure. Non-empty values are still checked against the registered translations exactly as before. Matches how user creation already behaves elsewhere - the CLI'suser createcommand never sets a language either.Verification
Added
TestLanguageValidatorAllowsEmptyString;go test ./pkg/user/...passes.