The `submit_permission` dependency causes duplicate validation errors

Offen
#1,812 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 2 Tagen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
Ein halber Tag
Anfängerfreundlichkeit
45/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
fastapi, python
Bereich
backend

Rechercherichtung

The duplicate errors come from the submit_permission dependency deserialising the request body separately from the main /api/v1/tasks endpoint. Start by finding that dependency and where it reads TaskRequest, then compare it with a test endpoint that has no dependency, which returns one error. Done means one validation error for an invalid TaskRequest on the tasks endpoint, with the existing tests still passing.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Found while looking into #1802, if an invalid TaskRequest is passed to the /api/v1/tasks endpoint, two validation errors are returned instead of the expected one.

$ curl -H "Authorization: Bearer ${TOKEN}" http://localhost:8000/api/v1/demo --json '{"name": "count", "params": [], "instrument_session": "cm12345-1"}' | jq
{
  "detail": [
    {
      "type": "dict_type",
      "loc": [
        "body",
        "params"
      ],
      "msg": "Input should be a valid dictionary",
      "input": []
    },
    {
      "type": "dict_type",
      "loc": [
        "body",
        "params"
      ],
      "msg": "Input should be a valid dictionary",
      "input": []
    }
  ]
}

This seems to be from deserialising the task for the main endpoint, as well as for the submit_permission. Passing the same JSON to a test endpoint without the dependency returns a single error.

Vorherrschende Sprache
Python
Sterne
14
Forks
15
Ø Merge
3 T. 2 Std.
Gemergte PRs (30 T.)
35

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus DiamondLightSource/blueapi

Alle Issues in DiamondLightSource/blueapi

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.