Skip to content

fix(ai): bedrock-media MIME tables read through the prototype chain — media type "constructor" bypasses the unsupported-type error #916

Closed

Description

@dezren39

Problem

packages/ai/src/protocols/utils/bedrock-media.ts routes media by MIME type with two bare table reads:

  • :97 — const imageFormat = IMAGE_FORMATS[mime as keyof typeof IMAGE_FORMATS]
  • :105 — const documentFormat = DOCUMENT_FORMATS[mime as keyof typeof DOCUMENT_FORMATS]

mime is the caller-supplied media type (part.media.mediaType.toLowerCase()), an arbitrary string. A bare record[key] read walks the prototype chain, so a media type of "constructor", "toString", or "__proto__" resolves to an inherited Object member (truthy) instead of missing. The if (imageFormat) / if (documentFormat) checks therefore pass with a function/object as the "format", bypassing the clear unsupported-media-type errors this function exists to produce, and a malformed Bedrock image/document block (format = the Object function) is built instead.

This is the #833 prototype-chain class, found while dispositioning the packages/ai hits for #912 (extending the check:proto-reads gate to packages/ai/src). It is filed separately per #912's acceptance criteria rather than allowlisted silently.

Evidence (main 61b359a25b)

Acceptance criteria

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    priority/lowNice to have; do when convenient
    effort/xsTrivial: expected under 30 minutes of work
    on Oct 29, 2026
  2. developing-today commented on Oct 29, 2026

    @developing-today
  3. dezren39 commented on Oct 29, 2026

    @dezren39
    Author

    🤖 Agent note · filed

  4. dezren39 commented on Oct 29, 2026

    @dezren39
    Author

    🤖 Agent note · picked up

    • Agent: issue sweep (issue-sweep-rotating)
    • Session / ID: issue-sweep-rotating run 2026-10-29 15:24 CDT (2026-10-29T20:26:20Z)
    • Found via: sweep pickup
    • Task: Guard bedrock-media IMAGE_FORMATS/DOCUMENT_FORMATS reads against prototype-chain keys and add regression test
    • Expectation: effort xs; done = PR opened (and merged if checks green) with prototype-named media types falling through to unsupported-type errors
  5. added
    work/self-assignedAn agent grabbed this item directly, outside the queue
    and removed on Oct 29, 2026
  6. dezren39 commented on Oct 29, 2026

    @dezren39
    Author

    🤖 Agent note · handed off

  7. dezren39 commented on Oct 29, 2026

    @dezren39
    Author

    🤖 Agent note · done

    • Agent: issue sweep (issue-sweep-rotating)
    • Session / ID: issue-sweep-rotating run 2026-10-29 15:24 CDT (2026-10-29T20:53:28Z)
    • Found via: sweep pickup
    • Task: PR fix(ai): guard bedrock-media MIME tables against prototype-chain reads #921 MERGED (squash 4619e76); issue closed by the merge. CI: linux unit/typecheck/affected/e2e/compliance/standards all pass; windows unit failed only on the unrelated gitHasReader timing test (5002ms timeout, job 123714333961) — pre-existing flake stream, change verified sound (laptop bedrock-media + media tests 12 pass, ai typecheck clean).
    • Expectation: done — prototype-named media types now fall through to the unsupported-media-type error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/lowNice to have; do when convenientstatus:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions