fix(harness): use mediaType instead of mimeType in sendMessage file parts#6
fix(harness): use mediaType instead of mimeType in sendMessage file parts#6saddlepaddle wants to merge 2 commits into
Conversation
Replace images-only API with files array that supports arbitrary file
types (images, PDFs, text files). The harness now accepts
`files: Array<{ data, mediaType, filename? }>` instead of
`images: Array<{ data, mimeType }>`.
Includes a temporary debug log to verify the new code path is active.
WalkthroughThe pull request modifies file attachment handling in the sendMessage method within the harness module. A single property field in the file part is renamed from Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
🚥 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)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
1 issue found across 1 file
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/core/src/harness/harness.ts">
<violation number="1" location="packages/core/src/harness/harness.ts:1192">
P1: Temporary debug `console.info` should not be shipped to production. It logs the first 60 characters of every attached file's raw data, which may contain sensitive user content (base64-encoded documents, PII, etc.). Remove this block before merging, or gate it behind a debug/verbose flag.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| tracingContext?: TracingContext; | ||
| tracingOptions?: TracingOptions; | ||
| }): Promise<void> { | ||
| console.info( |
There was a problem hiding this comment.
P1: Temporary debug console.info should not be shipped to production. It logs the first 60 characters of every attached file's raw data, which may contain sensitive user content (base64-encoded documents, PII, etc.). Remove this block before merging, or gate it behind a debug/verbose flag.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/core/src/harness/harness.ts, line 1192:
<comment>Temporary debug `console.info` should not be shipped to production. It logs the first 60 characters of every attached file's raw data, which may contain sensitive user content (base64-encoded documents, PII, etc.). Remove this block before merging, or gate it behind a debug/verbose flag.</comment>
<file context>
@@ -1189,6 +1189,15 @@ export class Harness<TState extends HarnessStateSchema = HarnessStateSchema> {
tracingContext?: TracingContext;
tracingOptions?: TracingOptions;
}): Promise<void> {
+ console.info(
+ '\n🎉🎉🎉 MASTRACODE FILE SUPPORT IS ALIVE! 🎉🎉🎉\n' +
+ ` content: ${JSON.stringify(content?.slice(0, 80))}...\n` +
</file context>
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 `@packages/core/src/harness/harness.ts`:
- Around line 1239-1244: The harness is emitting file parts with mediaType but
downstream code (AIV5Adapter, Agent) and the FilePartType type in step-schema.ts
still expect mimeType, causing undefined MIME types; update all consumers
(search for AIV5Adapter methods at lines referencing .mimeType, Agent code that
reads .mimeType, and any uses within sendMessage) to read .mediaType instead,
and update the FilePartType definition in step-schema.ts to rename mimeType to
mediaType (or add mediaType alongside mimeType for backward compatibility),
ensuring all references and type checks use the new field name consistently.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 6f62ad27-3920-4184-a795-a08e1ceef26b
📒 Files selected for processing (1)
packages/core/src/harness/harness.ts
| return { | ||
| type: 'file' as const, | ||
| data: f.data, | ||
| mimeType: f.mediaType, | ||
| mediaType: f.mediaType, | ||
| filename: f.filename, | ||
| }; |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check if AIV5Adapter and Agent code have been updated to handle mediaType field
echo "=== Checking AIV5Adapter file part handling ==="
rg -n -C5 'part\.mimeType|part\.mediaType' --type=ts -g '**/AIV5Adapter.ts'
echo ""
echo "=== Checking Agent file part handling ==="
rg -n -C5 'part\.mimeType|part\.mediaType' --type=ts -g '**/agent.ts'
echo ""
echo "=== Checking FilePartType definition ==="
rg -n -C3 'FilePartType' --type=ts -g '**/step-schema.ts'
echo ""
echo "=== Searching for mediaType field usage in message adapters ==="
rg -n 'mediaType' --type=ts -g '**/adapters/**'Repository: superset-sh/mastra
Length of output: 7472
Field name mismatch between harness output and downstream consumers will result in undefined MIME types.
The change from mimeType to mediaType at line 1242 creates an inconsistency with code that consumes these file parts. AIV5Adapter (lines 205-206, 220) and Agent (line 1713) explicitly read .mimeType from the file parts passed through sendMessage(). Additionally, the FilePartType definition in step-schema.ts still uses mimeType as the field name. When harness sends mediaType, these downstream consumers will receive undefined for the MIME type, breaking file type detection and categorization in the agent.
All consumers of input file parts must be updated to read mediaType instead of mimeType, and the FilePartType type definition must be updated to match.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/core/src/harness/harness.ts` around lines 1239 - 1244, The harness
is emitting file parts with mediaType but downstream code (AIV5Adapter, Agent)
and the FilePartType type in step-schema.ts still expect mimeType, causing
undefined MIME types; update all consumers (search for AIV5Adapter methods at
lines referencing .mimeType, Agent code that reads .mimeType, and any uses
within sendMessage) to read .mediaType instead, and update the FilePartType
definition in step-schema.ts to rename mimeType to mediaType (or add mediaType
alongside mimeType for backward compatibility), ensuring all references and type
checks use the new field name consistently.
Description
Fixes a typo in the file part construction in
harness.sendMessage()— the propertymimeTypeshould bemediaType.This causes file parts to be routed through the V4 adapter instead of the V5 adapter, since the V5
FileParttype expectsmediaType.Introduced in mastra-ai#13574.
Type of Change
Checklist