fix(harness): use mediaType instead of mimeType in sendMessage file parts#13833
Conversation
…arts The file part object passed `mimeType` instead of `mediaType`, causing file attachments to be routed through the V4 adapter instead of V5. Introduced in mastra-ai#13574.
|
@saddlepaddle is attempting to deploy a commit to the Mastra Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: d2d05d0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 21 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughFixes file attachment handling in the harness by renaming the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.changeset/fix-harness-file-mediatype.md:
- Line 5: Rewrite line 5 to an outcome-first, action-verb phrasing that
emphasizes user impact: e.g., "Fixed file attachments being routed to the wrong
adapter by correcting a typo from `mimeType` to `mediaType` in the `sendMessage`
file part construction, ensuring attachments are processed by AI SDK v5
providers." Reference the `sendMessage` change (typo `mimeType` → `mediaType`)
and the resulting fix for V4→V5 adapter routing in the message.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d164fe14-9dda-4331-a8a2-6ab0943fd890
📒 Files selected for processing (2)
.changeset/fix-harness-file-mediatype.mdpackages/core/src/harness/harness.ts
| '@mastra/core': patch | ||
| --- | ||
|
|
||
| Fix `mimeType` → `mediaType` typo in `sendMessage` file part construction. This caused file attachments to be routed through the V4 adapter instead of V5, preventing them from being correctly processed by AI SDK v5 providers. |
There was a problem hiding this comment.
Use an outcome-first, action-verb phrasing in the changeset.
Line 5 is accurate, but it reads implementation-heavy. Please rewrite with a direct user-impact statement and start with an action verb like “Fixed.”
✏️ Suggested wording
-Fix `mimeType` → `mediaType` typo in `sendMessage` file part construction. This caused file attachments to be routed through the V4 adapter instead of V5, preventing them from being correctly processed by AI SDK v5 providers.
+Fixed file attachments in `sendMessage` by using `mediaType`. Attachments are now handled correctly by AI SDK v5 providers.potential_issue
As per coding guidelines: "Use action-oriented verbs (Added, Fixed, Improved...)" and "Highlight outcomes... Do not focus on internal implementation details."
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| Fix `mimeType` → `mediaType` typo in `sendMessage` file part construction. This caused file attachments to be routed through the V4 adapter instead of V5, preventing them from being correctly processed by AI SDK v5 providers. | |
| Fixed file attachments in `sendMessage` by using `mediaType`. Attachments are now handled correctly by AI SDK v5 providers. |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.changeset/fix-harness-file-mediatype.md at line 5, Rewrite line 5 to an
outcome-first, action-verb phrasing that emphasizes user impact: e.g., "Fixed
file attachments being routed to the wrong adapter by correcting a typo from
`mimeType` to `mediaType` in the `sendMessage` file part construction, ensuring
attachments are processed by AI SDK v5 providers." Reference the `sendMessage`
change (typo `mimeType` → `mediaType`) and the resulting fix for V4→V5 adapter
routing in the message.
…arts (#13833) ## Summary Fixes a typo in `Harness.sendMessage()` where file parts were constructed with `mimeType` instead of `mediaType`. This caused file attachments to be routed through the V4 adapter instead of V5, preventing them from being correctly processed by AI SDK v5 providers. ## Change **`packages/core/src/harness/harness.ts`** ```diff - return { type: 'file' as const, data: f.data, mimeType: f.mediaType, filename: f.filename }; + return { type: 'file' as const, data: f.data, mediaType: f.mediaType, filename: f.filename }; ``` ## Context The `files` parameter was added in #13574, but the file part construction used `mimeType` (V4 format) instead of `mediaType` (V5 format). The AI SDK v5 `FilePart` type expects `mediaType`, so using `mimeType` causes the part to not match the expected shape and fall through to the legacy adapter path. This bug is present in `@mastra/core@1.9.0` on npm. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **Bug Fixes** * Corrected file attachment metadata naming in the message system to ensure files are properly routed and processed by supported AI SDK providers. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
…arts (#13833) ## Summary Fixes a typo in `Harness.sendMessage()` where file parts were constructed with `mimeType` instead of `mediaType`. This caused file attachments to be routed through the V4 adapter instead of V5, preventing them from being correctly processed by AI SDK v5 providers. ## Change **`packages/core/src/harness/harness.ts`** ```diff - return { type: 'file' as const, data: f.data, mimeType: f.mediaType, filename: f.filename }; + return { type: 'file' as const, data: f.data, mediaType: f.mediaType, filename: f.filename }; ``` ## Context The `files` parameter was added in #13574, but the file part construction used `mimeType` (V4 format) instead of `mediaType` (V5 format). The AI SDK v5 `FilePart` type expects `mediaType`, so using `mimeType` causes the part to not match the expected shape and fall through to the legacy adapter path. This bug is present in `@mastra/core@1.9.0` on npm. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **Bug Fixes** * Corrected file attachment metadata naming in the message system to ensure files are properly routed and processed by supported AI SDK providers. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary
Fixes a typo in
Harness.sendMessage()where file parts were constructed withmimeTypeinstead ofmediaType. This caused file attachments to be routed through the V4 adapter instead of V5, preventing them from being correctly processed by AI SDK v5 providers.Change
packages/core/src/harness/harness.tsContext
The
filesparameter was added in #13574, but the file part construction usedmimeType(V4 format) instead ofmediaType(V5 format). The AI SDK v5FileParttype expectsmediaType, so usingmimeTypecauses the part to not match the expected shape and fall through to the legacy adapter path.This bug is present in
@mastra/core@1.9.0on npm.Summary by CodeRabbit
Release Notes