Describe the bug
When submitting queries via POST /v1/statement, the trino-python-client sends the request body with Content-Type: text/plain without a charset parameter. This causes issues with Trino Gateway's requestAnalyzerConfig feature, which requires the charset to be explicitly set in order to parse the SQL body for routing rule evaluation.
Expected behavior
The client should send Content-Type: text/plain; charset=utf-8 since the Trino client protocol uses UTF-8 encoded SQL strings.
Actual behavior
The client sends Content-Type: text/plain without charset, causing Trino Gateway to log:
DEBUG io.trino.gateway.ha.router.TrinoQueryProperties charset is not set in the request
And the Gateway fails to read the SQL body, resulting in empty catalogs, tables, and body fields in trinoQueryProperties. This breaks all SQL-aware routing rules.
Steps to reproduce
- Set up Trino Gateway with
requestAnalyzerConfig.analyzeRequest: true
- Submit a query using
trino-python-client:
from trino.dbapi import connect
conn = connect(
host="gateway-host",
port=38080,
user="test",
)
cur = conn.cursor()
cur.execute("SELECT * FROM catalog.schema.table LIMIT 1")
- Observe that the Gateway cannot parse the SQL body
Workaround
Set the Content-Type header explicitly via a custom requests.Session:
import requests
http_session = requests.Session()
http_session.headers.update({
"Content-Type": "text/plain; charset=utf-8"
})
conn = connect(
host="gateway-host",
port=38080,
http_session=http_session,
# ...
)
Log output
No response
Operating System
Redhat
Trino Python client version
0.337.0
Trino Server version
477
Python version
3.13.12
Additional context
Related Trino Gateway issue: trinodb/trino-gateway#1032
While the Gateway should ideally handle missing charset by defaulting to UTF-8, the client should also follow best practices by including the charset in the Content-Type header.
Are you willing to submit PR?
Describe the bug
When submitting queries via
POST /v1/statement, thetrino-python-clientsends the request body withContent-Type: text/plainwithout a charset parameter. This causes issues with Trino Gateway'srequestAnalyzerConfigfeature, which requires the charset to be explicitly set in order to parse the SQL body for routing rule evaluation.Expected behavior
The client should send
Content-Type: text/plain; charset=utf-8since the Trino client protocol uses UTF-8 encoded SQL strings.Actual behavior
The client sends
Content-Type: text/plainwithout charset, causing Trino Gateway to log:And the Gateway fails to read the SQL body, resulting in empty
catalogs,tables, andbodyfields intrinoQueryProperties. This breaks all SQL-aware routing rules.Steps to reproduce
requestAnalyzerConfig.analyzeRequest: truetrino-python-client:Workaround
Set the Content-Type header explicitly via a custom
requests.Session:Log output
No response
Operating System
Redhat
Trino Python client version
0.337.0
Trino Server version
477
Python version
3.13.12
Additional context
Related Trino Gateway issue: trinodb/trino-gateway#1032
While the Gateway should ideally handle missing charset by defaulting to UTF-8, the client should also follow best practices by including the charset in the Content-Type header.
Are you willing to submit PR?