I’ve got a database where I am using customer’s first and last name and email address to create a new user. I am also using the user’s first and last name to create a channel for each user. This is all working so far if all my users are in English languages. I plan on deploying this to other countries and languages where user’s name will not fit within the character limit of Couchbase: Valid channel names consist of text letters [A–Z, a–z], digits [0–9], and a few special characters [= + / . , _ @]
What is the recommended workaround for this? Do I need to encode the names of the user to a recommended format before creating the user account and corresponding channel?
Some of the languages I need to support are: Korean, Chinese (Simplified), Chinese (Traditional), Japanese, Russian, Spanish, German, Polish, Swedish. Dutch, Italian.
Or you could %-encode the string but change the % character to, say, @. (We’ve been considering relaxing the character set restriction on channel names, but I don’t think it’s happened yet.)
There is no length limit for channel names. Usernames might be implicitly limited by the maximum key length in Couchbase Server, since IIRC internally we store a document in the bucket named after the username; if so, the limit would be about 245 bytes.
I am getting an “400 invalid name error” when I try to create a user and channel if I base64 encode the user name and channel name. Any particular reason why I am getting this error? It looks like the string has all valid characters and is short enough where it’s under the size limit.
I looked into the user-handling code in Sync Gateway, and the character set for usernames (and role names) is restricted to alphanumerics and -+.@. So I would suggest trimming the = signs from the base64 output; they’re only there as placeholders anyway.
(I don’t know why the discrepancy. The user and channel code were implemented at different times and I don’t think anyone thought to make the naming consistent.)