Skip to content

Validate mimeType in ImageContentBlock.FromBytes and AudioContentBlock.FromBytes#1321

Merged
stephentoub merged 3 commits intomainfrom
copilot/fix-exception-for-null-mime-type
Feb 20, 2026
Merged

Validate mimeType in ImageContentBlock.FromBytes and AudioContentBlock.FromBytes#1321
stephentoub merged 3 commits intomainfrom
copilot/fix-exception-for-null-mime-type

Conversation

Copy link
Contributor

Copilot AI commented Feb 20, 2026

ImageContentBlock.FromBytes and AudioContentBlock.FromBytes silently accepted null/whitespace mimeType, producing invalid content blocks. Now throws ArgumentNullException/ArgumentException via Throw.IfNullOrWhiteSpace.

  • Added Throw.IfNullOrWhiteSpace(mimeType) guard to both FromBytes methods
  • Replaced incorrect <exception cref="InvalidOperationException"> XML doc with ArgumentNullException and ArgumentException
  • Added theory tests covering null, "", and " " inputs for both methods

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…ntBlock.FromBytes

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix FromBytes methods to throw exception for null or whitespace mime type Validate mimeType in ImageContentBlock.FromBytes and AudioContentBlock.FromBytes Feb 20, 2026
Copilot AI requested a review from stephentoub February 20, 2026 01:59
@stephentoub stephentoub requested a review from ericstj February 20, 2026 02:05
@stephentoub stephentoub marked this pull request as ready for review February 20, 2026 02:05
@stephentoub stephentoub enabled auto-merge (squash) February 20, 2026 02:07
@stephentoub stephentoub merged commit 539481f into main Feb 20, 2026
9 checks passed
@stephentoub stephentoub deleted the copilot/fix-exception-for-null-mime-type branch February 20, 2026 03:47
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.

3 participants

Comments