fix(auth): deserialize listed secrets when recursive is enabled - #12810
davidsbatista merged 2 commits into
Conversation
|
@Lesereingrape is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
|
Hi @Lesereingrape, thanks a lot for your contribution! 🙏 We noticed that the Contributor License Agreement (CLA) check ( To get your PR reviewed, please sign the CLA via the link in the |
Pull request was converted to draft
|
@Lesereingrape you need to sign the license agreement in the next few days otherwise the PR will be closed |
|
Thanks for signing the CLA, @Lesereingrape! 🎉 This PR is now ready for review again and the reviewer has been re-assigned. |
Related Issues
Proposed Changes:
deserialize_secrets_inplacechecked "is this value a dict and is recursion on?" before "is this key one of the secrets I was asked to restore?". Since a serializedSecretis itself a dict ({'type': 'env_var', 'env_vars': [...], 'strict': ...}), every listed key was captured by the recursion branch withrecursive=True, so theSecret.from_dictbranch was unreachable for precisely the inputs it exists to serve — enabling recursion made the helper restore fewer secrets than disabling it. The recursive call also omitted therecursiveargument, so the traversal stopped one level below the top.The change reorders the two conditions inside the same loop and forwards the flag:
recursive=True;recursive=Falsebehavior is byte-for-byte what it was (the first branch requiredrecursiveanyway).Impact for users:
haystack.utils.deserialize_secrets_inplaceis the helper the docs recommend for rebuilding secrets in a custom component'sfrom_dict; withrecursive=Truecallers kept plain dicts where aSecretwas expected, and the failure surfaced later asAttributeError: 'dict' object has no attribute 'resolve_value'.How did you test it?
Added 4 unit tests to
test/utils/test_auth.py(that file had no coverage of this helper before):main..._deserializes_listed_keys(control,recursive=False)..._leaves_non_secret_nested_dicts_untouched(control)..._deserializes_listed_keys_when_recursivedict)..._recurses_into_nested_dicts(depth 3)dict)Environment note, stated plainly:
hatchis not available on my machine, so I did not runhatch run test:unit/hatch run test:types. I ran against an editable install of this checkout (haystack 3.2.0-rc0,import haystackresolving to the clone, Python 3.13) withpytestdirectly. For lint I ran the repository's pinned ruff (v0.16.0, the rev in.pre-commit-config.yaml) on the changed files —All checks passed!/2 files already formatted— plus the repo's ownscripts/release_note_backticks.pyon the new release-note file (exit 0).mypywas not run. Pre-commit hooks are not installed in my clone, so the individual hook tools above were run directly rather than throughpre-commit run --all-files;codespellwas not run. CI will be the first full check.Notes for the reviewer
haystack/utils/auth.py:234-238changes; the release note is inreleasenotes/notes/fix-deserialize-secrets-recursive-388f1fab3ec25639.yaml.keys), and a listed key whose dict value is not a secret dict will now reachSecret.from_dictwhilerecursive=Truewhere before it was skipped.Secret.from_dictraises on a missing/unknowntype, so that case becomes a clear error instead of a silent pass-through — I judged that preferable to guessing, and theNonecase stays untouched.Secret.from_env_var); its hunks are at:63,:183,:211and do not overlap this loop, so the two changes should rebase cleanly in either order.Checklist
recursivedocstring already described the fixed behavior, so no docstring change was needed.)fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.ruff0.16.0 check + format,release_note_backticks.py) and they are clean; I could not runhatch,mypyor the full hook suite locally — see "How did you test it?" for the exact scope.