Skip to content

Conversation

@FoxHelms
Copy link
Contributor

@FoxHelms FoxHelms commented Dec 8, 2025


^ 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.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@BasPH
Copy link
Contributor

BasPH commented Dec 9, 2025

For reference: #55015

Copy link
Contributor

@BasPH BasPH left a 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:

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

@FoxHelms
Copy link
Contributor Author

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 BoundLoggerLazyProxy. Is this test sufficient?

@BasPH
Copy link
Contributor

BasPH commented Dec 11, 2025

Tested this exact scenario on a live Vault, looking good:
image

Will check the unit test next

@BasPH
Copy link
Contributor

BasPH commented Dec 11, 2025

@FoxHelms Can we replicate this check for fetching connections (which requires key "conn_uri") and config too?

@FoxHelms
Copy link
Contributor Author

@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?

@FoxHelms FoxHelms marked this pull request as ready for review December 15, 2025 21:51
@FoxHelms FoxHelms force-pushed the hashicorp-secrets-errors branch 2 times, most recently from d70b5fa to eafb7fe Compare December 23, 2025 19:43
@Lee-W Lee-W force-pushed the hashicorp-secrets-errors branch from ec41ad1 to ec80c9d Compare January 5, 2026 09:26
@FoxHelms FoxHelms force-pushed the hashicorp-secrets-errors branch from 0a41906 to 9830375 Compare January 5, 2026 18:59
@FoxHelms FoxHelms requested a review from BasPH January 5, 2026 19:00
@Lee-W
Copy link
Member

Lee-W commented Jan 6, 2026

Looks like there're some compatibility issues we need to resolve due to the log import

@FoxHelms
Copy link
Contributor Author

FoxHelms commented Jan 8, 2026

Fixed!

@pierrejeambrun
Copy link
Member

@BasPH The PR was updated, do you mind giving this another review to reconsider your request for change. :)

@BasPH
Copy link
Contributor

BasPH commented Jan 20, 2026

Thanks for the persistence on this @FoxHelms!

@BasPH BasPH merged commit 57146f0 into apache:main Jan 20, 2026
85 checks passed
jason810496 pushed a commit to jason810496/airflow that referenced this pull request Jan 22, 2026
* 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
amoghrajesh pushed a commit to astronomer/airflow that referenced this pull request Jan 22, 2026
* 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
suii2210 pushed a commit to suii2210/airflow that referenced this pull request Jan 26, 2026
* 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
shreyas-dev pushed a commit to shreyas-dev/airflow that referenced this pull request Jan 29, 2026
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:hashicorp Hashicorp provider related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants