micropython / micropython/micropython-lib

Urequest.request is not handling urls properly

Aperta
#673 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Python
Stelle
2.9k
Fork
1.1k
Merge medio
7g 6h
PR unite (30g)
3

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia dalla chiamata a urequests.request mostrata nell’issue, confrontando l’invocazione POST con l’URL Firestore stampata. Riproduci la richiesta verso l’URL fornito e determina se il segmento finale del percorso viene preservato; il lavoro è completato quando la richiesta raggiunge il documento Firestore previsto senza l’errore malformed-parent segnalato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
api, networking
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.