-
Notifications
You must be signed in to change notification settings - Fork 16.4k
more explicit secrets path error messages (#55015) #59224
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
Conversation
|
For reference: #55015 |
BasPH
left a comment
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.
Hi @FoxHelms, thanks for opening the PR! #55015 states that the error message isn't meaningful when the variable/connection path exists, but the required keys "value" or "conn_uri" inside the Vault secret aren't found.
Those checks happen here:
return response.get("value") if response else None return response.get("value") if response else None uri = response.get("conn_uri")
Currently, Airflow simply returns None (for variable/config) or an empty Connection, and doesn't tell the user those keys weren't found. It ends up throwing this rather generic error.
I think Airfow should be more explicit here: could you log a more meaningful error in the Vault provider? I'm thinking something like this (untested)?
if not response:
return None
try:
return response["value"]
except KeyError:
self.log.warning('Vault secret %s fetched but does not have required key "value"', key)
return None|
Got it @BasPH, thanks for the feedback! I implemented your suggestion. I've tried to also test that the logger shows the correct warning, but I've been having trouble mocking it because its a |
|
@FoxHelms Can we replicate this check for fetching connections (which requires key "conn_uri") and config too? |
|
@BasPH I just updated get_config and get_connection. I'm not sure how to test get_connection because the function always returns a connection, and get_uri always returns a string. Maybe that unit test is unnecessary and displaying the warning message is sufficient? |
providers/hashicorp/src/airflow/providers/hashicorp/secrets/vault.py
Outdated
Show resolved
Hide resolved
d70b5fa to
eafb7fe
Compare
ec41ad1 to
ec80c9d
Compare
0a41906 to
9830375
Compare
|
Looks like there're some compatibility issues we need to resolve due to the log import |
|
Fixed! |
|
@BasPH The PR was updated, do you mind giving this another review to reconsider your request for change. :) |
|
Thanks for the persistence on this @FoxHelms! |
* more explicit secrets path error messages * explicitly catch no value key error * reformat invalid path message * more explicit error getting vault config without value key * explicit error when vault conn_uri key not present * removing warnings from get connection * fixing invalid path message format * remove whitespace * mocking logs in unit test * simplify single use variables * fixing log patch package import * using back compatible package
* more explicit secrets path error messages * explicitly catch no value key error * reformat invalid path message * more explicit error getting vault config without value key * explicit error when vault conn_uri key not present * removing warnings from get connection * fixing invalid path message format * remove whitespace * mocking logs in unit test * simplify single use variables * fixing log patch package import * using back compatible package
* more explicit secrets path error messages * explicitly catch no value key error * reformat invalid path message * more explicit error getting vault config without value key * explicit error when vault conn_uri key not present * removing warnings from get connection * fixing invalid path message format * remove whitespace * mocking logs in unit test * simplify single use variables * fixing log patch package import * using back compatible package
* more explicit secrets path error messages * explicitly catch no value key error * reformat invalid path message * more explicit error getting vault config without value key * explicit error when vault conn_uri key not present * removing warnings from get connection * fixing invalid path message format * remove whitespace * mocking logs in unit test * simplify single use variables * fixing log patch package import * using back compatible package
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rstor{issue_number}.significant.rst, in airflow-core/newsfragments.