Added functionality to list variable keys w optional prefix filter via task-sdk#61595
Added functionality to list variable keys w optional prefix filter via task-sdk#61595justinpakzad wants to merge 1 commit intoapache:mainfrom
Conversation
|
The issue is that none of the secrets backend actually suports It's possible that we might want to change it and have some (or all) of the backends to actually support listing keys - but that is a bigger change and I think if we decide to do it - it should at least be discussed in the devlist - where we could make decision about the scope of it and how it would impact exposing keys also in Airflow UI and CLIs. |
Yea, that makes sense. As I was working on this I realized it's not as simple as just adding a way to "list keys", hence why I stated some of my doubts in the description lol. I guess a discussion on if or how something like this could be supported would be interesting, but yea that might something for the future. |
related: #61166
Opened this PR to implement a way to list variable keys (optionally by prefix) via the task SDK. The ask in the issue was to support fetching variables where the keys might not be known beforehand.
I've implemented a
list_keys()method in the Variable class with an optional prefix parameter. Example:Variable.list_keys()orVariable.list_keys(prefix="api_")There were some architectural decisions I was unsure about. For example, whether a method like
list_keys()should be part of the Variable class or if it should live elsewhere, given that variable represents a single k/v pair. Also, the existing router dependency expects a key as a path parameter, but that wouldn't work here, meaning I needed to move that to the function level and exclude it from the list keys endpoint. Lastly, there could be a path conflict with the existing/{variable_key:path}route. For now I just used/keys/list, but that's probably not ideal (maybe a separate router?).Anyways, opening this up for a discussion.
Was generative AI tooling used to co-author this PR?
Generated-by: [Claude Sonnet 4.5] following the guidelines
{pr_number}.significant.rstor{issue_number}.significant.rst, in airflow-core/newsfragments.