fix(profile): exclude connection_url from selectable datasources
Summary
wren profile add --interactiveand--uiboth offerconnection_urlas a datasource choice, but it is not aDataSource— picking it saves a profile that no connector can ever resolve (ValueError: 'connection_url' is not a valid DataSource).- Fix: add
get_selectable_datasources()for the two user-facing pickers.get_datasource_options()is left untouched, deliberately — see below.
Motivation
get_datasource_options() returns every key of DATASOURCE_MODELS, and that dict carries one entry which is a connection form, not a datasource. The repo says so itself, in tests/test_field_registry.py:
# (connection_url is extra — not a DataSource enum value but valid.)
That list is fed straight to the pickers:
profile_cli.py→click.Choice(ds_choices, case_sensitive=False)for theData sourcepromptprofile_web.py→datasource_options→<option value="connection_url">in the form
So a user can pick it, and the saved profile is unusable:
>>> DataSource('connection_url')
ValueError: 'connection_url' is not a valid DataSource
Fix
The obvious fix — dropping connection_url from get_datasource_options() — would introduce a secret leak, so I did not do it.
profile.py::_registry_sensitive_keys iterates get_datasource_options() to collect every SecretStr field, and ConnectionUrl.connection_url is a SecretStr. Removing the entry drops connection_url out of the mask set, and wren profile debug would start printing full database URLs (user:password@host) in plaintext. The function's docstring states exactly why it spans everything:
"The set spans all datasources because a profile may carry a cross-datasource secret (e.g.
connection_url); over-masking a benign key in a diagnostic dump is harmless, under-masking a secret is not."
Change set, measured rather than reasoned about: set(get_selectable_datasources()) == set(get_datasource_options()) - {"connection_url"}, and no DataSource enum member is dropped.
So the two consumers need two different semantics, and this PR gives them exactly that:
| consumer | needs | this PR |
|---|---|---|
profile_cli prompt, profile_web form |
real datasources | → get_selectable_datasources() |
_registry_sensitive_keys (masking) |
all connection models | unchanged |
docs.py |
uses DATASOURCE_MODELS directly |
unchanged (docs should cover connection_url) |
Verification
- New tests:
tests/test_field_registry.py::test_selectable_datasources_excludes_non_datasource_entries— every option is a realDataSource.tests/test_field_registry.py::test_selectable_datasources_keeps_every_real_datasource— reverse anchor: filtering drops nothing genuine; the delta is exactly{connection_url}.tests/test_profile_web.py::test_form_omits_connection_url_datasource— the rendered form has no<option value="connection_url">.tests/test_profile_cli.py::test_interactive_add_does_not_offer_connection_url— the prompt'sclick.Choicelist excludes it, and still offerspostgres/bigquery.
- Red checks were run per call site, reverting only the call site (reverting the whole change would raise
ImportErroron the new function — that is not a red check):- web site reverted →
assert '<option value="connection_url"' not in resp.text— RED - CLI site reverted →
assert 'connection_url' not in [... 'connection_url' ...]— RED - The existing
test_form_contains_datasource_optionsstays green under both, so it was not hollowed out.
- web site reverted →
- Suites vs clean
main, verbatim: UI job 55 → 59 passed,tests/test_profile_cli.py+tests/test_profile.py63 → 64 passed (+5 = exactly the new tests; 0 new failures). Lint clean (just lint). - Coverage note, in the interest of accuracy:
tests/test_profile_cli.pyis not run by any CI job (CI runstests/unit/,tests/connectors/*,tests/test_profile_web.py+tests/test_field_registry.py, and the memory/mcp files). The registry and web regressions above are covered by theui testsjob; the CLI one is local-only.
License
core/** is Apache-2.0 per the repo LICENSE path map — this contribution is within an Apache-2.0 path.
Summary by CodeRabbit
-
Bug Fixes
- Profile creation now displays only valid datasource choices.
- Removed the non-selectable
connection_urloption from interactive and web-based profile forms.
-
Tests
- Added coverage to verify valid datasource options remain available and are presented in sorted order.
- Added checks confirming
connection_urlis excluded from both profile creation interfaces.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: d8ebc3b2-e4dc-458f-960b-b5291a62e1cc
📥 Commits
Reviewing files that changed from the base of the PR and between 243eec883e12657791bcf911f4c2f2de6638bfa8 and e742d7e22dc4b57f9494fafa0f0e1a48c2a521c9.
📒 Files selected for processing (6)
core/wren/src/wren/model/field_registry.pycore/wren/src/wren/profile_cli.pycore/wren/src/wren/profile_web.pycore/wren/tests/test_field_registry.pycore/wren/tests/test_profile_cli.pycore/wren/tests/test_profile_web.py
Walkthrough
The datasource registry now provides a DataSource-enum-backed selectable list. Profile creation in the CLI and web UI uses this list, excluding connection_url, while retaining the broader registry options for other callers. Tests cover filtering, ordering, and both interfaces.
Changes
Datasource profile options
| Layer / File(s) | Summary |
|---|---|
Datasource registry filtering core/wren/src/wren/model/field_registry.py, core/wren/tests/test_field_registry.py |
Adds get_selectable_datasources() to return sorted DataSource-backed registry keys and tests its exclusion, completeness, ordering, and relationship to the broader options helper. |
Profile flow datasource choices core/wren/src/wren/profile_cli.py, core/wren/src/wren/profile_web.py, core/wren/tests/test_profile_cli.py, core/wren/tests/test_profile_web.py |
Updates CLI and web profile creation to use selectable datasource values and verifies that connection_url is absent while real datasource options remain available. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Suggested reviewers: goldmedal
Poem
A rabbit hops through fields so neat,
Choosing sources fit to meet.
connection_urlstays out of sight,
While Postgres and BigQuery shine bright.
The profile form now feels just right!
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title clearly and accurately summarizes the main change: removing connection_url from profile datasource selection. |
| Docstring Coverage | ✅ Passed | Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✨ Finishing Touches
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.