micropython / micropython/micropython-lib
Urequest.request is not handling urls properly
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 1.1k
- Avg merge
- 7d 6h
- Merged PRs (30d)
- 3
Description
I was supposed to post the changes made for my entry in the database in Firestore, when this error popped up:
{
"error": {
"code": 400,
"message": "Document parent name \"projects/vendo-app-979f8/databases/(default)/documents/products\" lacks \"/\" at index 63.",
"status": "INVALID_ARGUMENT"
}
}
I tracked the error down and printed the final path before being sent to Firestore. Here's the code used to send, as well as the link that was being sent using urequest.request:
def send_request(path, method="GET", params=dict(), data=None, dump=True):
headers = {}
if FIREBASE_GLOBAL_VAR.ACCESS_TOKEN:
headers["Authorization"] = "Bearer " + FIREBASE_GLOBAL_VAR.ACCESS_TOKEN
if method == "POST":
print(path)
response = urequests.request(method, path, data=None, json=data)
else:
response = urequests.request(method, path, headers=headers)
if dump == True:
if response.status_code < 200 or response.status_code > 299:
print(response.text)
raise FirestoreException(response.reason, response.status_code)
jsonResponse = response.json()
if jsonResponse.get("error"):
error = json["error"]
code = error["code"]
message = error["message"]
raise FirestoreException(message, code)
return jsonResponse
And the path printed:
https://firestore.googleapis.com/v1/projects/vendo-app-979f8/databases/(default)/documents/products/001
why won't urequest recognize the last part of the url? And is there a fix to it?
Thanks for the help in advance.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the urequests.request call shown in the issue, comparing the POST invocation with the printed Firestore URL. Reproduce the request against the supplied URL and determine whether the final path segment is preserved; done means the request reaches the intended Firestore document without the reported malformed-parent error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100