Skip to content

fix: expand env_var substitution in profile option values#20

Open
theiotidiot wants to merge 1 commit into
columnar-tech:mainfrom
theiotidiot:fix/profile-env-var-substitution
Open

fix: expand env_var substitution in profile option values#20
theiotidiot wants to merge 1 commit into
columnar-tech:mainfrom
theiotidiot:fix/profile-env-var-substitution

Conversation

@theiotidiot

Copy link
Copy Markdown

Summary

When connecting via databow --profile NAME, option values that use the ADBC {{ env_var(NAME) }} substitution template are forwarded to the driver as literal strings instead of being expanded against the process environment. Profiles that lean on env-var substitution to inject credentials or URIs (per the ADBC connection-profile spec) therefore fail at connect time.

adbc_driver_manager performs this substitution along its DriverLocator::Profile path (via process_profile_value), but initialize_profile_connection loads the profile through FilesystemProfileProvider directly and skips that step. This patch applies process_profile_value to every OptionValue::String returned by the profile, matching the driver manager's own behavior.

Test plan

  • Added test_profile_env_var_substitution integration test that points DuckDB at a database file whose name comes from an env var and asserts the substituted path exists on disk while the literal-template path does not — fails on main, passes with this change.
  • cargo fmt
  • cargo test — 16 passed.
  • Verified end-to-end against a real ADBC driver using a profile whose uri contains {{ env_var(...) }} for the auth token.

Fixes #19

The ADBC connection-profile spec specifies that profile option values containing
`{{ env_var(NAME) }}` are expanded against the process environment when the
profile is loaded. `adbc_driver_manager` performs this expansion when callers
go through its `DriverLocator::Profile` path (via `process_profile_value`),
but databow's `initialize_profile_connection` loads the profile through
`FilesystemProfileProvider` directly and forwards the resulting `OptionValue`s
to the driver without applying the substitution. Profiles that reference env
vars therefore fail at connect time because the literal template string reaches
the driver.

Apply `process_profile_value` to every `OptionValue::String` returned by the
profile, matching the driver manager's own behavior. Add a regression test
that asserts the expanded value reaches the driver (the test points DuckDB at
a database file whose name comes from an env var and verifies the substituted
path exists on disk while the literal-template path does not).

Fixes columnar-tech#19
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.

Profile option values are not expanded with env_var substitution

1 participant