Skip to content

fix(serializer): mask pydantic secret values - #1886

Merged
hassiebp merged 4 commits into
mainfrom
hassiebbot/mask-pydantic-secrets-a817
Sep 16, 2026
Merged

hassiebp merged 4 commits into
mainfrom
hassiebbot/mask-pydantic-secrets-a817

Conversation

@hassiebp

@hassiebp hassiebp commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Prevents Pydantic SecretStr and SecretBytes wrappers from being reflected into serialized trace data. The serializer now returns a stable <secret> placeholder before generic object handling.

Adds focused coverage for bare secrets and secrets nested in Pydantic models.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Refactor
  • Documentation update
  • Tooling, CI, or repo maintenance

Verification

LANGFUSE_PUBLIC_KEY=<synthetic> LANGFUSE_SECRET_KEY=<synthetic> LANGFUSE_BASE_URL=http://127.0.0.1:9999 uv run --frozen pytest -n auto --dist worksteal tests/unit
# 691 passed, 2 skipped, 34 warnings

uv run --frozen ruff check .
# All checks passed!

uv run --frozen ruff format --check langfuse/_utils/serializer.py tests/unit/test_serializer.py
# 2 files already formatted

uv run --frozen mypy langfuse --no-error-summary
# passed

A direct trace-attribute serialization check confirmed neither synthetic raw value remains in the serialized input and both values serialize as <secret>.

The repository-wide format check was not used as evidence because unrelated tests/unit/test_media.py is already reported as needing reformatting; both changed files pass the format check.

Checklist

  • I self-reviewed the diff using code_review.md.
  • I added or updated tests for behavior changes.
  • Docs, examples, and .env.template do not require updates.
  • I did not hand-edit generated files.
  • I did not commit secrets or credentials.
Open in Web Open in Cursor 

RetriggerConfidence Score: 3/5

This PR is not safe to merge because it adds assertions for secret masking without implementing that masking, leaving the disclosure path unresolved.

Summary

This PR adds regression tests intended to ensure Pydantic SecretStr and SecretBytes values are masked during event serialization, both as bare values and within Pydantic models. However, it does not add the serializer behavior required by those assertions.

  • Adds parameterized coverage for bare Pydantic secret wrappers.
  • Adds coverage for secret fields in a Pydantic model.
  • Leaves the generic serializer paths capable of traversing the wrappers' underlying secret values.

Reviews (1) · Last reviewed commit: "test(serializer): cover pydantic secret ..."

Co-authored-by: Hassieb Pakzad <hassiebp@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

@claude review

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

No review was started: this request came from a bot account. Manual reviews can only be requested by someone with write access to this repository. Ask a maintainer to comment @claude review, or have your automation post the comment from a user account with write access.

Tip: disable this comment in your organization's Code Review settings.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 16, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-16T13:35:37.483284Z 5ad676f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

cursoragent and others added 2 commits September 16, 2026 13:33
Co-authored-by: Hassieb Pakzad <hassiebp@users.noreply.github.com>
Co-authored-by: Hassieb Pakzad <hassiebp@users.noreply.github.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5ad676f92a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tests/unit/test_serializer.py Outdated
Comment thread tests/unit/test_serializer.py Outdated
Comment thread tests/unit/test_serializer.py Outdated
Co-authored-by: Hassieb Pakzad <hassiebp@users.noreply.github.com>
@hassiebp
hassiebp merged commit 23c5963 into main Sep 16, 2026
19 checks passed
@hassiebp
hassiebp deleted the hassiebbot/mask-pydantic-secrets-a817 branch September 16, 2026 16:11
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.

2 participants