more explicit secrets path error messages (#55015)#59224
Conversation
|
For reference: #55015 |
BasPH
left a comment
There was a problem hiding this comment.
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:
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? |
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
* 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.