Skip to content

Conversation

dumkydewilde
Copy link

@dumkydewilde dumkydewilde commented Sep 18, 2025

Resolves #12028

Problem

On programatic invocations, i.e. using dbtRunner.invoke(), the runner fails when e.g. a profiles_dir is specified. This appears to be because, when this is provided as a keyword argument (e.g. dbtRunner.invoke(["build"], profiles_dir='./my_profiles') the kwargs are only passed to the context after creation, meaning any validation on creating the context fails. And this is exactly what happens, because the profiles_dir option checks for type=click.Path(exists=True).

Why is this annoying? Because everytime you run this in a Docker container (or e.g. through an orchestrator) it will fall back to the default directory for this option (~/username/.dbt) which it of course doesn't find.

Solution

Params can not be added to the Click context before it is created, which means they have to be added as string arguments. flags.py already provides functionality for this with the command_params() function. What we can do is take the kwargs through this function, and combine them with provided args so that params can be set before the context creation and validation happens.

Checklist

  • I have read the contributing guide and understand what's expected of me.
  • I have run this code in development, and it appears to resolve the stated issue.
  • This PR includes tests, or tests are not required or relevant for this PR.
  • This PR has no interface changes (e.g., macros, CLI, logs, JSON artifacts, config files, adapter interface, etc.) or this PR has already received feedback and approval from Product or DX.
  • This PR includes type annotations for new and modified functions.

@dumkydewilde dumkydewilde requested a review from a team as a code owner September 18, 2025 13:41
Copy link

cla-bot bot commented Sep 18, 2025

Thanks for your pull request, and welcome to our community! We require contributors to sign our Contributor License Agreement and we don't seem to have your signature on file. Check out this article for more information on why we have a CLA.

In order for us to review and merge your code, please submit the Individual Contributor License Agreement form attached above above. If you have questions about the CLA, or if you believe you've received this message in error, please reach out through a comment on this PR.

CLA has not been signed by users: @dumkydewilde

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community This PR is from a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] On programatic invocations CLI params with type checks cause failures

1 participant