Skip to content

Python: Make Content base64 documentation examples runnable - #9467

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 2 commits into
microsoft:mainfrom
BlueRaddish:fix/oct17-mm-ms
Oct 22, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 2 commits into
microsoft:mainfrom
BlueRaddish:fix/oct17-mm-ms

Conversation

@BlueRaddish

@BlueRaddish BlueRaddish commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Motivation & Context

The Content.from_data() documentation example raises ValueError: Invalid base64 data provided. when copied because its placeholder is truncated. This follow-up completes the same documentation repair already in this PR: the from_uri() example also needed its detector import, a supported f-string, and decodable example data.

Description & Review Guide

  • What are the major changes? Use the detector documentation's base64 PNG signature in the from_data() example and the from_uri() prose. The combined PR also imports detect_media_type_from_base64 and assigns the media type before constructing the URI.
  • What is the impact of these changes? Documentation only. The runtime AST and public APIs are unchanged. The eight decoded bytes are a PNG signature, not a complete PNG image.
  • What do you want reviewers to focus on? Copying the complete examples into clean interpreters, and the consistency between the URI prose and code.

Fresh verification against this PR's previous published head reproduces one genuine from_data() failure. The existing complete from_uri() and metadata predicate examples pass as positive controls; their behavior was not changed. All three final docstring examples execute using public imports and compile under real Python 3.10 and 3.11 interpreters. All 478 owning tests in packages/core/tests/core/test_types.py -m "not integration" pass with no failures or skips. Scoped checks and the real source commit's normal pre-commit hook pass. The full workspace test suite and image decoding were not run. Exact follow-up source verification.

The original URI syntax/import reproduction belongs to the earlier verification. The fresh result above does not count those earlier failures again.

Related Issue

N/A - trivial change. This is an obvious correction to broken documentation examples, with no runtime behavior change. The complete open-PR changed-path audit and matching diffs contain no competing repair beyond this existing PR.

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: OpenAI Codex assisted with diagnosis, documentation corrections, regression verification, and this description.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) - a workflow keeps the label and title prefix in sync automatically.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@BlueRaddish
BlueRaddish deployed to github-app-auth October 17, 2026 08:03 — with GitHub Actions Active
@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Oct 17, 2026
@BlueRaddish BlueRaddish changed the title Python: Make the URI content example runnable Python: Make Content base64 documentation examples runnable Oct 18, 2026
@BlueRaddish
BlueRaddish deployed to github-app-auth October 18, 2026 11:38 — with GitHub Actions Active
@BlueRaddish
BlueRaddish deployed to github-app-auth October 18, 2026 11:38 — with GitHub Actions Active
@BlueRaddish

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The corrected examples are valid across the supported Python versions: the base64 string decodes to the PNG signature, media-type detection succeeds, and the simplified data-URI f-string is runnable with the required import.

Merged via the queue into microsoft:main with commit 74f3447 Oct 22, 2026
50 checks passed

This branch was successfully deployed

1 active deployment
github-app-auth — efcfa0b9 Deployed Oct 18, 2026 by BlueRaddish via add_label #25673
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants