harbor run -t openthoughts/tasktrove-openswe-tasks-patched-v5-oracle-success-openswe_oss-26996harbor download openthoughts/tasktrove-openswe-tasks-patched-v5-oracle-success-openswe_oss-26996The repository has not been cloned yet. Run the following command first to clone the repo, check out the target commit, and install dependencies:
bash /setup_files/setup.sh
The code will then be available at /testbed.
You are working on the repository dlt-hub/dlt (instance: dlt-hub__dlt-2437).
The code is located in /testbed.
##2398 rest_api: v1.8 GraphQL payload fails REST API config validation
1.8.0, 1.8.1
dlt version 1.8.0 introduced a new (and very useful) feature to extract query string and JSON parameters to define resource relationships.
A side-effect of that change is that it limits the JSON data we can send in the request body, for example a POST request to a GraphQL API, as this change now validates the content of the JSON body.
Prior to dlt 1.8 I could define a RESTAPIConfig like:
from dlt.sources.rest_api import RESTAPIConfig, rest_api_resources
config: RESTAPIConfig = {
"client": {
"base_url": "https://www.example.com",
},
"resources": [
{
"name": "artists",
"endpoint": {
"path": "",
"method": "POST",
"json": {
"query": """
query Artist {
artist(id: "123") {
id
name
}
}
""",
},
"data_selector": "data.artist",
},
},
],
}
yield from rest_api_resources(config)
However this now fails validation with a ValueError: Expression ' artist(id' defined in json is not valid. Valid expressions must start with one of: resources
I think this is caused by this change now validating the JSON param.
Is there a way we could either disable validation on a given resource - or provide a JSON body that isn't validated? Possibly this is just stretching the REST API source too far and I should just build a GraphQL source?
No response
from dlt.sources.rest_api import RESTAPIConfig, rest_api_resources
config: RESTAPIConfig = {
"client": {
"base_url": "https://www.example.com",
},
"resources": [
{
"name": "artists",
"endpoint": {
"path": "",
"method": "POST",
"json": {
"query": """
query Artist {
artist(id: "123") {
id
name
}
}
""",
},
"data_selector": "data.artist",
},
},
],
}
yield from rest_api_resources(config)
macOS
Local
3.12
REST
DuckDB
No response
No response