airbytehq / airbytehq/airbyte

Lowcode server: generate proper exception types

Offen
#19,324 9 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area/connector-builder python-codegen team/marketplace team/triage technical-debt type/enhancement
Vorherrschende Sprache
Python
Sterne
22.1k
Forks
5.3k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

## Tell us about the problem you're trying to solve
The FastAPI framework typically [handles errors](https://fastapi.tiangolo.com/tutorial/handling-errors/) by expecting the developer to `raise` them as Exceptions sub-classing `HTTPException`. The Framework then transforms it to the correct HTTP response, and returns it to the API consumer.

In our [OpenAPI spec](https://github.com/airbytehq/airbyte/blob/master/airbyte-connector-builder-server/src/main/openapi/openapi.yaml) we define some error responses e.g: it defines that when returning 400s, the `KnownException` type should be used.

But the generated code is just a "plain old object" -- it does not subclass `HTTPException`. This causes a problem: if an endpoint `raise`s a `KnownException` we get the following error:

```
File "/Users/lakemossman/code/airbyte/airbyte-connector-builder-server/./connector_builder/impl/default_api.py", line 63, in list_streams
raise KnownExceptionInfo(message="failure")
TypeError: exceptions must derive from BaseException
```

## Describe the solution you’d like
I would like the autogenerated exception classes to extend the `HTTPException` class defined by FastAPI.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

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