🐛 Bug Report: Document creation failed when using url attribute
👟 Reproduction steps
When I create a new collection with an url attribute and try to create a new document in it, on the web editor or as api request, with this url:
https://www.amazon.de/AMAZONAS-Hängemattengestell-RockStone-größenverstellbar-270-330/dp/B005HGW6A4
I get an error message: Invalid document structure: Attribute "buy_url" has invalid format. Value must be a valid URL
👍 Expected behavior
It should create the document with the url attribute
👎 Actual Behavior
It can't create the document when I use an url attribute.
🎲 Appwrite version
Version 0.15.x
💻 Operating system
Linux
🧱 Your Environment
I have a Hetzner root Server with debian Linux and run appwrite with docker-compose instead of the docker command.
👀 Have you spent some time to check if this issue has been raised before?
- [X] I checked and didn't find similar issue
🏢 Have you read the Code of Conduct?
- [X] I have read the Code of Conduct
Kindly share your code.
Sure, here the error in the web editor and the minimal code:

const db = new Databases(
this.client,
"62f7b51b49389fe3a0a6"
);
db.createDocument(
"62f7b5201284ef2ef2f7",
"NewDocumentId",
{
url: 'https://www.amazon.de/AMAZONAS-Hängemattengestell-RockStone-größenverstellbar-270-330/dp/B005HGW6A4'
},
['role:all'],
[`user:62f3eb06921b14c925a7`]
);
And this code gives this error
{
"message": "Invalid document structure: Attribute \"url\" has invalid format. Value must be a valid URL",
"code": 400,
"type": "document_invalid_structure",
"version": "0.15.3"
}
The collection attributes are these:

I had a thought and tried it https://www.amazon.de/AMAZONAS-Hngemattengestell-RockStone-grenverstellbar-270-330/dp/B005HGW6A4 <- this would be a valid URL. So, the regex or whatever checks in appwrite if it is a valid URL, seams to have problems with handling German Umlaute "äöüß" in the path part of the URL.
Good guess. Although, it would be difficult to create a regex rule that supports all languages. So i suggest you keep sanitizing the url for special letters for now. You can equally just paste the url into the browser address bar, then copy paste it back into the field. It should already be translated.
@Rinma, thank you for raising this issue! 🙏 . We use PHP's filter_var() to validate URLs:
https://github.com/appwrite/appwrite/blob/5b4a3805bf7a1ee54cb562fd525dd471069a4cdd/src/Appwrite/Network/Validator/URL.php#L52
It looks like it doesn't handle some special characters. I'll talk to the team about how we can improve this!
hey @Rinma I want to contribute to this issue . Can you please allow me ?
@aakash-kumar-gorai, go for it! Please make sure to add test cases and validate the URL is correct when inserted into the Database and when it is retrieved. 🙏
@stnguyen90 there's no update from @aakash-kumar-gorai can you assign it to me?
Sure, @MahendraBishnoi29!
also @stnguyen90 can guide me where to make changes because it's my first contribution here :)
@MahendraBishnoi29, see my previous comment.
@Rinma, thank you for raising this issue! 🙏 . We use PHP's
filter_var()to validate URLs:https://github.com/appwrite/appwrite/blob/5b4a3805bf7a1ee54cb562fd525dd471069a4cdd/src/Appwrite/Network/Validator/URL.php#L52
It looks like it doesn't handle some special characters. I'll talk to the team about how we can improve this!
@stnguyen90 are you talking about this one? 🤔
@stnguyen90 are you talking about this one? 🤔
Yes, @MahendraBishnoi29.
@stnguyen90 are you talking about this one? 🤔
Yes, @MahendraBishnoi29.
sorry, I'm not much familiar with PHP so still didn't get it? 😔
@MahendraBishnoi29, sounds like you'll need to find some resources on PHP. If this is too difficult, let me know and I'll unassign you from this issue.
@stnguyen90 ok
@MahendraBishnoi29, any progress on this or should I unassign you?
@MahendraBishnoi29, any progress on this or should I unassign you?
yes go ahead.
@stnguyen90 can you assign it to me ?
@Sooraj-s-98 Since this is an Hacktoberfest labeled issue, please ask for reassignment when the hacktoberfest starts officially😄
Hey @Rinma @stnguyen90, I would like to work on this if its not yet done!
@stnguyen90 can you assign me ? Please check PR
@SaurabhNandy, thanks for your interest! 🙏 Happy hacking!
@Sooraj-s-98, we're assigning people on a first come first serve basis after hacktoberfest starts. If @SaurabhNandy isn't able to complete the issue, we're reassign accordingly. I'm the meantime, you can look for another hacktoberfest issue via our website.
@stnguyen90 can you check my PR ?