Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: Secure API key representation in __repr__ method to prevent cred…#34365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
liu-jin-yi wants to merge1 commit intolangchain-ai:master
base:master
Choose a base branch
Loading
fromliu-jin-yi:fix/issue-34356

Conversation

@liu-jin-yi
Copy link

…ential leakage

  • Added customrepr methods to ChatOpenAI, BaseOpenAI, and OpenAIEmbeddings classes
  • API keys are now redacted showing only first 3 and last 4 characters (e.g., 'sk-...wxyz')
  • Short keys (< 8 chars) are completely masked with '***'
  • Callable API key providers are also properly masked
  • Added comprehensive unit tests to verify the fix

Fixes#34356

(Replace this entire block of text)

Read the full contributing guidelines:https://docs.langchain.com/oss/python/contributing/overview

Thank you for contributing to LangChain! Follow these steps to have your pull request considered as ready for review.

  1. PR title: Should follow the format: TYPE(SCOPE): DESCRIPTION
  1. PR description:
  • Write 1-2 sentences summarizing the change.
  • If this PR addresses a specific issue, please include "Fixes #ISSUE_NUMBER" in the description to automatically close the issue when the PR is merged.
  • If there are any breaking changes, please clearly describe them.
  • If this PR depends on another PR being merged first, please include "Depends on #PR_NUMBER" inthe description.
  1. Runmake format,make lint andmake test from the root of the package(s) you've modified.
  • We will not consider a PR unless these three are passing in CI.

Additional guidelines:

  • We ask that if you use generative AI for your contribution, you include a disclaimer.
  • PRs should not touch more than one package unless absolutely necessary.
  • Do not update theuv.lock files unless or add dependencies topyproject.toml files (even optional ones) unless you have explicit permission to do so by a maintainer.

@github-actionsgithub-actionsbot added integrationPR made that is related to a provider partner package integration openai`langchain-openai` package issues & PRs labelsDec 15, 2025
@liu-jin-yi
Copy link
Author

fix#34356

@codspeed-hq
Copy link

codspeed-hqbot commentedDec 15, 2025
edited
Loading

CodSpeed Performance Report

Merging#34365 willnot alter performance

Comparingliu-jin-yi:fix/issue-34356 (6a20474) withmaster (6cff82d)1

Summary

✅ 6 untouched
⏩ 28 skipped2

Footnotes

  1. No successful run was found onmaster (b8a76cb) during the generation of this report, so6cff82d was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 28 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase,click here and archive them to remove them from the performance reports.

@liu-jin-yiliu-jin-yi changed the titleFix: Secure API key representation in __repr__ method to prevent cred…fix: Secure API key representation in __repr__ method to prevent cred…Dec 16, 2025
@github-actionsgithub-actionsbot added the fixFor PRs that implement a fix labelDec 16, 2025
@liu-jin-yiliu-jin-yiforce-pushed thefix/issue-34356 branch 2 times, most recently froma6a4217 toc44fddbCompareDecember 16, 2025 01:31
…ential leakage- Added custom __repr__ methods to ChatOpenAI, BaseOpenAI, and OpenAIEmbeddings classes- API keys are now redacted showing only first 3 and last 4 characters (e.g., 'sk-...wxyz')- Short keys (< 8 chars) are completely masked with '***'- Callable API key providers are also properly masked- Added comprehensive unit tests to verify the fixFixeslangchain-ai#34356
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@ccurmeccurmeAwaiting requested review from ccurmeccurme is a code owner

@mdrxymdrxyAwaiting requested review from mdrxymdrxy is a code owner

Assignees

No one assigned

Labels

fixFor PRs that implement a fixintegrationPR made that is related to a provider partner package integrationopenai`langchain-openai` package issues & PRs

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

API keys exposed in object representation (__repr__) of ChatOpenAI and other clients

1 participant

@liu-jin-yi

[8]ページ先頭

©2009-2025 Movatter.jp