Skip to content

Ensure SecretStr is cast to str on load for model clients#5947

Merged
ekzhu merged 2 commits intomainfrom
load_secrets_propertly_vd
Mar 14, 2025
Merged

Ensure SecretStr is cast to str on load for model clients#5947
ekzhu merged 2 commits intomainfrom
load_secrets_propertly_vd

Conversation

@victordibia
Copy link
Copy Markdown
Contributor

Why are these changes needed?

Currently we have SecretStr type for model clients to promote security best practices.

  • when we dump_component, keys are serialized as SecreteStr ..
  • when we load_component ... SecreteStr type is passed to the client in the api_key field. This i causes the type problems as the clients expect a string type.

This PR updates the from_config method for model clients to ensure we get the value from SecretStr.

Related issue number

Closes #5944

Checks

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 14, 2025

Codecov Report

Attention: Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 75.76%. Comparing base (296de52) to head (e2a1e5d).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...xt/src/autogen_ext/models/openai/_openai_client.py 60.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5947      +/-   ##
==========================================
- Coverage   75.77%   75.76%   -0.01%     
==========================================
  Files         191      191              
  Lines       13100    13107       +7     
==========================================
+ Hits         9927     9931       +4     
- Misses       3173     3176       +3     
Flag Coverage Δ
unittests 75.76% <75.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ekzhu ekzhu merged commit b8b7a2d into main Mar 14, 2025
@ekzhu ekzhu deleted the load_secrets_propertly_vd branch March 14, 2025 17:15
ekzhu pushed a commit that referenced this pull request Mar 14, 2025
Currently we have SecretStr type for model clients to promote security
best practices.

- when we dump_component, keys are serialized  as SecreteStr ..
- when we load_component ... SecreteStr type is passed to the client in
the api_key field. This i causes the type problems as the clients expect
a string type.

This PR updates the from_config method for model clients to ensure we
get the value from SecretStr.

Closes #5944
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Connection error with AzureOpenAI after latest merge

2 participants