fix: handle null name parameter in user creation endpoints#11215
fix: handle null name parameter in user creation endpoints#11215njg7194 wants to merge 1 commit intoappwrite:mainfrom
Conversation
Fixes appwrite#8785 When a client explicitly sends `name: null` in the request body, the API now properly handles it instead of returning a vague server error. Changes: - Wrap Text(128) validator with Nullable() for the name parameter - Accept nullable string (?string) in action functions - Use null coalescing operator ($name ?? '') when calling createUser This makes the name parameter consistent with email and phone parameters which already use the Nullable wrapper.
📝 WalkthroughWalkthroughThis change modifies user creation API endpoints to accept Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Security Scan Results for PRDocker Image Scan Results
Source Code Scan Results🎉 No vulnerabilities found! |
What does this PR do?
Fixes #8785
Problem
When a client explicitly sends
name: nullin the request body to any of the user creation endpoints (POST /v1/users, /v1/users/bcrypt, /v1/users/md5, etc.), the API returns a vague server error instead of handling it gracefully.Solution
The
nameparameter now uses theNullablevalidator wrapper (consistent withemailandphoneparameters that already handle null values):new Text(128)tonew Nullable(new Text(128))string $nameto?string $name$name ?? '') when passing tocreateUser()functionAffected Endpoints
Testing
name: nullnow creates user with empty name (same as not sending name at all)name: "John"works as beforeRelated Issue
Fixes #8785