-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Avoid access to profile when calling str(UnsetProfileConfig) #5209
fix: Avoid access to profile when calling str(UnsetProfileConfig) #5209
Conversation
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, don't hesitate to ping @drewbanin. CLA has not been signed by users: @tomasfarias |
CLA was just signed a minute ago 👍 |
dbt.config.UnsetProfileConfig inherits __str__ from dbt.config.Project. Moreover, UnsetProfileConfig also raises an exception when attempting to access unset profile attributes. As Project.__str__ ultimately calls to_project_config and accesses said profile attributes, we override to_project_config in UnsetProfileConfig to avoid accessing the attributes that raise an exception. This allows calling str(UnsetProfileConfig) and repr(UnsetProfileConfig). Basic unit testing is also included in commit.
c5301e7
to
097d24a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tomasfarias Thanks for putting up this amazing PR! Looks great to me! I will get the GHA all running and get it merged!
Sorry that it took me a bit to come back to the issue.
…t-labs#5209) * fix: Avoid access to profile when calling str(UnsetProfileConfig) dbt.config.UnsetProfileConfig inherits __str__ from dbt.config.Project. Moreover, UnsetProfileConfig also raises an exception when attempting to access unset profile attributes. As Project.__str__ ultimately calls to_project_config and accesses said profile attributes, we override to_project_config in UnsetProfileConfig to avoid accessing the attributes that raise an exception. This allows calling str(UnsetProfileConfig) and repr(UnsetProfileConfig). Basic unit testing is also included in commit. * fix: Skip repr for profile fields in UnsetProfileConfig * chore(changie): Add changie file
resolves #5081
Description
dbt.config.UnsetProfileConfig
inherits__str__
fromdbt.config.Project
. Moreover,UnsetProfileConfig
raises an exception when attempting to access unset profile attributes. AsProject.__str__
ultimately callsProject.to_project_config
and accesses said profile attributes, we overrideto_project_config
inUnsetProfileConfig
to avoid accessing the attributes that raise an exception.This allows calling
str(UnsetProfileConfig)
without aRuntimeException
.Furthermore, setting both profile fields (
profile_name
andtarget_name
) torepr=False
allow us to callrepr(UnsetProfileConfig)
without aRuntimeException
.Basic unit testing is also included in commit.
Looks like my IDE also cleaned up some whitespace (runs
black
on save). I can revert it if needed.Checklist
changie new
to create a changelog entry