Skip to content

test(connector-factory): stop TestValidateConfig depending on asyncpg - #168

Merged
zc277584121 merged 1 commit into
zilliztech:mainfrom
zc277584121:test/decouple-validate-config-from-optional-sdk
Jul 7, 2026
Merged

zc277584121 merged 1 commit into
zilliztech:mainfrom
zc277584121:test/decouple-validate-config-from-optional-sdk

Conversation

@zc277584121

Copy link
Copy Markdown
Collaborator

Summary

  • tests/test_connector_factory.py::TestValidateConfig had 2 failing cases in the default uv run --extra dev pytest environment (no asyncpg installed): test_wrong_type_with_no_coercion_path_is_rejected and test_unrecognized_field_is_rejected.
  • Root cause: both used "postgres" as the example connector. load_builtin() registers postgres inside a try/except ImportError: pass (same pattern for every optional-SDK connector), so without asyncpg installed, postgres is never registered, get_plugin_cls("postgres") returns None, and validate_config silently no-ops instead of validating — "DID NOT RAISE" was a test-environment gap, not a real bug in validate_config/PostgresConfig. Confirmed by installing --extra pg: all 8 TestValidateConfig cases pass against the real schema.
  • Fix: register a fake plugin with its own CONFIG_SCHEMA (mirroring PostgresConfig's dsn/max_read_rows shape), the same pattern the file already uses for _FakePlugin in the resolve_target tests above it. The class now exercises schema enforcement unconditionally, independent of which optional connector SDKs happen to be installed. postgres's real CONFIG_SCHEMA is untouched and still enforced in production.

Test plan

  • uv run --extra dev pytest tests/test_connector_factory.py — 61 passed (was 2 failed before).
  • Full suite uv run --extra dev pytest — 371 passed, 11 skipped, 0 failed.
  • Also verified with --extra all-connectors installed — still 61 passed, no regression either way.
  • ruff format --check / ruff check clean.

Two TestValidateConfig cases used "postgres" as the example connector
and failed in the default `uv run --extra dev pytest` environment
(no asyncpg installed): load_builtin() silently skips registering
postgres when its optional SDK is missing, so get_plugin_cls("postgres")
returned None and validate_config no-opped instead of validating --
"DID NOT RAISE" was a test-environment gap, not a real bug. Verified
by installing `--extra pg`: all 8 cases pass against the real
PostgresConfig schema.

Registers a fake plugin with its own CONFIG_SCHEMA (mirroring
PostgresConfig's dsn/max_read_rows shape) so the class exercises
schema enforcement unconditionally, the same way the existing
_FakePlugin already does for resolve_target. postgres's own
CONFIG_SCHEMA is untouched and still enforced in production.

Signed-off-by: Cheney Zhang <chen.zhang@zilliz.com>
@zc277584121
zc277584121 merged commit 069f3df into zilliztech:main Jul 7, 2026
8 checks passed
@zc277584121
zc277584121 deleted the test/decouple-validate-config-from-optional-sdk branch July 7, 2026 13:58
@zc277584121 zc277584121 mentioned this pull request Jul 10, 2026
6 tasks done
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.

1 participant