fix: apply toyaml filter to all secret-backed credential fields in profiles template#2124
fix: apply toyaml filter to all secret-backed credential fields in profiles template#2124
Conversation
…te + envsubst
- Add profiles.yml.template with plaintext docker targets and ${VAR} cloud placeholders
- Update test-warehouse.yml to use CI_WAREHOUSE_SECRETS with envsubst (+ PROFILES_YML fallback)
- Split test-all-warehouses.yml into test-docker (pull_request) and test-cloud (pull_request_target)
- Guard BigQuery keyfile extraction against missing key
- Use explicit envsubst '$SCHEMA_NAME' for fork PR path
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
…house) Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
…ipt + Jinja2 template - Add generate_profiles.py (click CLI) for rendering profiles from secrets - Convert profiles.yml.template to profiles.yml.j2 (Jinja2) - Use service-account-json method for BigQuery (no temp keyfile needed) - Elementary profile schema uses _elementary suffix via YAML merge keys - Simplify test-warehouse.yml Write dbt profiles step Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
…llback Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
…pull_request_target Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
👋 @devin-ai-integration[bot] |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughReplaces direct template variable rendering with the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/profiles/profiles.yml.j2`:
- Line 54: The template currently renders port with the toyaml filter which
preserves string types and can produce a quoted value; update the template so
redshift_port is emitted as an integer (e.g., coerce it with the Jinja2 int
filter or otherwise cast before rendering) or ensure CI_WAREHOUSE_SECRETS
provides redshift_port as a numeric JSON type; specifically change the usage
around redshift_port in the profiles.yml.j2 template (replace the toyaml usage
with an explicit integer cast like redshift_port|int or remove toyaml for this
field) so the resulting YAML contains an unquoted numeric port value.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
tests/profiles/profiles.yml.j2
…biguous strings Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
…ields Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/profiles/generate_profiles.py`:
- Around line 38-39: The code currently returns "{}" for instances of Undefined
in _yaml_inline, causing scalar secrets to render as empty dicts; update
_yaml_inline to return a quoted empty string (e.g., '""') for Undefined scalar
values so password/user/client_id become YAML scalar empty strings, while
preserving the existing "{}" behavior only for actual dict-like secret fields
(or detect dict-context where appropriate); reference the Undefined type and the
_yaml_inline function (and _NullUndefined.__str__ if needed) to implement this
change.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
tests/profiles/generate_profiles.py
…n toyaml Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/profiles/generate_profiles.py`:
- Around line 40-42: The current scalar pass-through returns non-string values
and reintroduces YAML coercion (e.g. "yes", "null", "123"); change the fallback
so it always returns a string and emits a quoted YAML scalar instead of
returning value directly: for the non-dict branch use yaml.safe_dump(value,
default_flow_style=True, default_style='"') (or equivalent dumper options) and
.strip() so the function always returns a str and preserves quoting for strings;
update the branch handling the variable named value and keep the existing dict
branch that uses yaml.dump.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
tests/profiles/generate_profiles.py
fix: apply toyaml filter to all secret-backed credential fields
Summary
Applies the
| toyamlJinja2 filter to all secret-backed credential fields intests/profiles/profiles.yml.j2. Previously onlybigquery_keyfileused this filter — all other secret values (snowflake, redshift, databricks, athena, bigquery project) were rendered as raw template variables.Without the filter, secret values that happen to be YAML-significant strings (e.g.
"yes"→ boolean,"123"→ integer,"null"→ None) would be silently misinterpreted by the YAML parser when dbt loadsprofiles.yml. Thetoyamlfilter (yaml.dump) properly quotes/escapes values to preserve their string type.Companion change to dbt-data-reliability PR #937.
Review & Testing Checklist for Human
toyamlfilter intests/profiles/generate_profiles.pyhandles plain string scalars correctly (not just dicts likebigquery_keyfile). Specifically, confirm thatyaml.dump("some_password", default_flow_style=True).strip()returns the string quoted/unquoted appropriately.redshift_port(typically an integer in the JSON secret) renders correctly throughtoyaml— e.g.yaml.dump(5439, default_flow_style=True).strip()should produce5439not'5439'.schema_namefields are intentionally not filtered — they are computed values, not raw secrets.Notes
Summary by CodeRabbit