Skip to content

Validate and route unknown connect() keywords - #41

Merged
vgvoleg merged 1 commit into
mainfrom
fix-silent-connect-kwargs
Aug 27, 2026
Merged

Validate and route unknown connect() keywords#41
vgvoleg merged 1 commit into
mainfrom
fix-silent-connect-kwargs

Conversation

@vgvoleg

@vgvoleg vgvoleg commented Aug 3, 2026

Copy link
Copy Markdown
Member

Fixes #40.

connect() stored leftover keywords in connection_kwargs and never read them. Through a SQLAlchemy URL every query parameter lands there, so ?disable_discovery=true was silently dropped with no way to tell it apart from an option that did not help.

Changes

  • prepare_driver_config_kwargs() in utils.py: routes leftover keywords into ydb.DriverConfig kwargs, resolving valid names from inspect.signature(ydb.DriverConfig.__init__) rather than a local list that would go stale as the SDK gains parameters.
  • Coerces string values by parameter annotation. URL query params arrive as strings, so ?disable_discovery=false was a truthy string and disabled discovery.
  • Raises ProgrammingError for unknown names, unparseable values, and options passed both directly and via driver_config_kwargs.
  • Driver options combined with ydb_session_pool now raise: no DriverConfig is built there, so accepting them would keep the same silent behavior.
  • auth_token together with credentials now raises. DriverConfig lets auth_token overwrite credentials; the keyword used to be dropped entirely, so this guard comes with making it live.

_additional_sdk_headers is untouched apart from being popped earlier, before validation runs — otherwise it would trip the new check on the shared-pool path.

Behavior change

Keywords that are silently ignored today start raising, including user:password@ in a URL (not a documented form in ydb-sqlalchemy). driver_config_kwargs passed alongside ydb_session_pool was ignored and now raises.

Verification

poetry run poe tests — 131 passed. poetry run poe lint green. Checked against a local YDB with the exact keywords SQLAlchemy produces: disable_discovery="true"True, "false"False, typos and username/passwordProgrammingError.

@vgvoleg
vgvoleg requested a review from LuckySting August 6, 2026 10:04
Leftover keywords were stored in connection_kwargs and never read, so a
mis-routed option like disable_discovery passed through a SQLAlchemy URL
was indistinguishable from one that did not help.

Route them into ydb.DriverConfig kwargs by introspecting its signature,
coerce string values (URL query params arrive as strings, so "false" was
truthy), and raise ProgrammingError on anything the driver cannot accept.

Fixes #40
@vgvoleg
vgvoleg force-pushed the fix-silent-connect-kwargs branch from 5c38743 to 2bb5b55 Compare August 27, 2026 11:31
@vgvoleg
vgvoleg merged commit 63c0b0f into main Aug 27, 2026
6 checks passed
@vgvoleg
vgvoleg deleted the fix-silent-connect-kwargs branch August 27, 2026 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

connect() silently discards unknown keywords, so a mis-routed option is indistinguishable from one that did not help

2 participants