Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DH-5527] Document error codes #417

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ curl -X 'POST' \
}'
```

### Run scripts
### How to migrate data between versions
Our engine is under ongoing development and in order to support the latest features, we provide scripts to migrate the data from the previous version to the latest version. You can find all of the scripts in the `dataherald.scripts` module. To run the migration script, execute the following command:

```
Expand Down
12 changes: 10 additions & 2 deletions docs/api.create_database_connection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,20 @@ HTTP 201 code response
}
}

HTTP 400 code response (if the db connection fails it returns a 400 error)
HTTP 400 code response (if the db connection fails it returns a 400 error), :doc:`here <api.error_codes>` you can find
all the error codes

.. code-block:: rst

{
"detail": "string"
"error_code": "string",
"message": "string",
"description": "string",
"detail": {
"alias": "string",
"use_ssh": false,
"connection_uri": "string"
}
}

**Example 1**
Expand Down
50 changes: 50 additions & 0 deletions docs/api.error_codes.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Error Codes
=============================

When encountering errors in the API, an error code and a brief explanation are provided,
along with a 400 HTTP status code, following this structure:

.. code-block:: rst

{
"error_code": "<error_code>",
"message": <error_message>,
"description": <description>,
"detail": {
<body_params>
}
}

**Error Codes:**

DB Connections

- `invalid_database_connection` - Unable to establish the database connection.
- `invalid_database_uri_format` - The `connection_uri` doesn't have the correct format.
- `ssh_invalid_database_connection` - The SSH connection failed.
- `empty_database` - Although the connection was established, there are no tables present.
- `database_connection_not_found` - Database resource could not be found.

Golden SQL

- `golden_sql_not_found` - Golden SQL resource not found.
- `invalid_golden_sql` - The Golden SQL doesn't have the correct format.

Finetuning Model

- `llm_model_not_supported` - The specified model is not supported.

SQL Generation

- `prompt_not_found` - Prompt resource not found.
- `sql_generation_not_created` - The SQL generation failed.
- `sql_injection` - The generated/provided SQL failed the injection validation.
- `sql_generation_not_found` - SQL generation resource not found.

NL Generation

- `nl_generation_not_created` - The NL generation failed.

**Other Errors**

- `invalid_object_id` - The provided string is not a valid ObjectId.
22 changes: 22 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,26 @@ Related endpoints are:
"metadata": "dict | None" // Optional, default None
}

Error Codes
---------------------
Certain errors are accompanied by an error code and an explanatory message. These errors trigger an HTTP 400 response
code.

**DB connection error code response example:**

.. code-block:: json

{
"error_code": "invalid_database_uri_format",
"message": "Invalid URI format: foo",
"description": null,
"detail": {
"alias": "foo",
"use_ssh": false,
"connection_uri": "gdfgdgAABl5e-dfg_-wErFJdFZeVXwnmew_dfg__WU-dfgdfa=="
}
}

.. toctree::
:hidden:

Expand Down Expand Up @@ -268,3 +288,5 @@ Related endpoints are:
api.cancel_finetuning
api.delete_finetuning
api.list_finetunings

api.error_codes
12 changes: 10 additions & 2 deletions docs/api.update_database_connection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,20 @@ HTTP 200 code response
}
}

HTTP 400 code response (if the db connection fails it returns a 400 error)
HTTP 400 code response (if the db connection fails it returns a 400 error), :doc:`here <api.error_codes>` you can find
all the error codes

.. code-block:: rst

{
"detail": "string"
"error_code": "string",
"message": "string",
"description": "string",
"detail": {
"alias": "string",
"use_ssh": false,
"connection_uri": "string"
}
}

**Example 1**
Expand Down
Loading