Skip to content

Add nullable validator for name parameter in CreateUser endpoints#11758

Open
sashank-27 wants to merge 2 commits intoappwrite:1.9.xfrom
sashank-27:fix-8785-add-nullable-to-user-name-parameter
Open

Add nullable validator for name parameter in CreateUser endpoints#11758
sashank-27 wants to merge 2 commits intoappwrite:1.9.xfrom
sashank-27:fix-8785-add-nullable-to-user-name-parameter

Conversation

@sashank-27
Copy link
Copy Markdown

…endpoints

This fix addresses issue #8785 where all Users.CreateUser endpoints returned a vague server error when null was provided for the name parameter.

Changes:

  • Changed name parameter from 'new Text(128)' to 'new Nullable(new Text(128))' in:
    • POST /v1/users
    • POST /v1/users/bcrypt
    • POST /v1/users/md5
    • POST /v1/users/argon2
    • POST /v1/users/sha
    • POST /v1/users/phpass
    • POST /v1/users/scrypt

This allows the name parameter to accept null values, consistent with other optional parameters like email and phone.

What does this PR do?

(Provide a description of what this PR does and why it's needed.)

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Screenshots may also be helpful.)

Related PRs and Issues

  • (Related PR or issue)

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

…endpoints

This fix addresses issue appwrite#8785 where all Users.CreateUser endpoints returned a vague server error when null was provided for the name parameter.

Changes:
- Changed name parameter from 'new Text(128)' to 'new Nullable(new Text(128))' in:
  - POST /v1/users
  - POST /v1/users/bcrypt
  - POST /v1/users/md5
  - POST /v1/users/argon2
  - POST /v1/users/sha
  - POST /v1/users/phpass
  - POST /v1/users/scrypt

This allows the name parameter to accept null values, consistent with other optional parameters like email and phone.
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 2, 2026

Greptile Summary

This PR fixes a vague server error (#8785) that occurred when null was explicitly supplied for the name parameter on any CreateUser endpoint. The fix replaces new Text(128) with new Nullable(new Text(128)) and changes the default value from '' to null across all eight hashed-password create-user routes, making name consistent with the pattern already used for email and phone.

Key observations:

  • The action handlers for all affected endpoints already declare ?string $name in their signatures, so no callback signature changes were needed.
  • The shared createUser helper (line 78) normalizes the value immediately with $name = $name ?? '';, so downstream database writes always receive a string — null propagation ends at the controller boundary.
  • The PR description lists 7 endpoints but the diff correctly includes 8 (the scrypt-modified route is also updated), which is the right behavior.
  • No API spec or example docs updates were included; if this project enforces keeping specs in sync with parameter changes, those may need to be updated separately.

Confidence Score: 5/5

  • Safe to merge — the change is minimal, consistent with existing nullable-param patterns, and has no risk of regression given the null-coalescing guard in createUser.
  • All P2 or lower. The fix is correct: validators now accept null, action handlers already accept ?string, and the helper normalizes null to empty string before any storage operation. No logic errors or breaking changes identified.
  • No files require special attention.

Important Files Changed

Filename Overview
app/controllers/api/users.php Wraps name param with Nullable and changes default to null across all 8 CreateUser endpoints; action handlers and createUser helper already handle nullable name safely.

Reviews (2): Last reviewed commit: "fix: add nullable validator to user name..." | Re-trigger Greptile

… CreateUser endpoint

This completes the fix for issue appwrite#8785 by adding the Nullable wrapper to the scrypt-modified endpoint that was missed in the initial commit.
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.

1 participant