fix(dlt): prevent credential type field overwriting db_type in format_config#5857
Draft
mary-mt wants to merge 2 commits into
Draft
fix(dlt): prevent credential type field overwriting db_type in format_config#5857mary-mt wants to merge 2 commits into
mary-mt wants to merge 2 commits into
Conversation
…_config
format_config initialises config = {"type": db_type} then iterates all
credential object attributes and writes them into config. BigQuery
service-account credentials carry a "type": "service_account" field
(from the GCP service account JSON format) which overwrites the
"bigquery" key. parse_connection_config then raises:
ConfigError: Unknown connection type 'service_account'
This error fires before model generation starts, even though the direct
caller (generate_dlt_models) discards the connection config entirely.
The bug only surfaces with BigQuery service-account credentials; OAUTH
credentials do not carry a conflicting type field.
Fix: move config["type"] = db_type to after the credential loop so it
cannot be overwritten by credential attributes.
Signed-off-by: Mary Akowe <mary.akowe@madetech.com>
Collaborator
|
Hi @mary-akowe! :) May you please review https://github.com/SQLMesh/sqlmesh/blob/main/CONTRIBUTING.md Some of your tests will fail (e.g., |
Signed-off-by: Mary Akowe <mary.akowe@madetech.com>
80187bd to
b927e56
Compare
Collaborator
|
It seems that you did not follow the contribution instructions. I'm seeing failures for make fast-test |
Author
Hello @mday-io, thanks for getting back on this. I initially ran make fast-tests (after following setup instructions), but did not get any failures come up.
Could you please clarify the errors you are referring? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sqlmesh dlt_refreshfails withError: Unknown connection type 'service_account'when the dlt pipeline uses BigQuery with service-account credentials.Root cause
format_configinitialisesconfig = {"type": db_type}(e.g."bigquery") then iterates all credential object attributes and writes them intoconfig. BigQuery service-account credentials carry a"type": "service_account"field (from the GCP service account JSON format). This overwrites the"bigquery"key.parse_connection_configthen raises:This error fires before model generation starts, even though the direct caller (
generate_dlt_models) discards the connection config entirely — it is the_in:The bug only surfaces with BigQuery service-account credentials. OAUTH credentials do not carry a conflicting
typefield, so anyone who testeddlt_refreshwith OAUTH would not have seen it.Fix
Move
config["type"] = db_typeto after the credential loop so it cannot be overwritten by credential attributes.def format_config(configs: t.Dict[str, str], db_type: str) -> str: """Generate a string for the gateway connection config.""" - config = { - "type": db_type, - } - + config: t.Dict[str, t.Any] = {} + for key, value in configs.items(): if key == "password": config[key] = f'"{value}"' elif key == "username": config["user"] = value else: config[key] = value + config["type"] = db_type + # Validate the connection config fieldsReproduction
sqlmesh dlt_refresh <pipeline_name>Error: Unknown connection type 'service_account'Does not affect OAUTH credentials.