Skip to content

Validate host in SQLAlchemy URL helper - #621

Merged
hashhar merged 1 commit into
trinodb:masterfrom
hashhar:hashhar/579-sqla-url-error
Aug 14, 2026
Merged

Validate host in SQLAlchemy URL helper#621
hashhar merged 1 commit into
trinodb:masterfrom
hashhar:hashhar/579-sqla-url-error

Conversation

@hashhar

@hashhar hashhar commented Jul 11, 2026

Copy link
Copy Markdown
Member

Description

trino.sqlalchemy.URL() built the connection string by concatenation and never validated the host argument. Passing a value that carries a scheme, port, path, or credentials (e.g. "https://example.com") produced a malformed URL that SQLAlchemy rejected with an opaque error:

ValueError: invalid literal for int() with base 10: ''

Reject such a host up front with a clear ArgumentError that names the offending value and shows the expected form.

Non-technical explanation

Validate host in SQLAlchemy URL helper. Fixes #579

Release notes

(x) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
( ) Release notes are required, with the following suggested text:

* Fix some things. ({issue}`issuenumber`)

Comment thread trino/sqlalchemy/util.py Outdated
trino.sqlalchemy.URL() built the connection string by concatenation and
never validated the host argument. Passing a value that carries a scheme,
port, path, or credentials (e.g. "https://example.com") produced a
malformed URL that SQLAlchemy rejected with an opaque error:

    ValueError: invalid literal for int() with base 10: ''

Reject such a host up front with a clear ArgumentError that names the
offending value and shows the expected form.
@hashhar
hashhar force-pushed the hashhar/579-sqla-url-error branch from 4d4b8db to 8a26ef6 Compare August 14, 2026 11:55
@hashhar

hashhar commented Aug 14, 2026

Copy link
Copy Markdown
Member Author

applied comments.

@hashhar
hashhar merged commit 5dbb996 into trinodb:master Aug 14, 2026
11 checks passed
@hashhar
hashhar deleted the hashhar/579-sqla-url-error branch August 14, 2026 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

Port incorrectly processed when using trino.sqlalchemy.URL and sa.create_engine

3 participants