Skip to content
This repository was archived by the owner on Apr 17, 2026. It is now read-only.

fix(harness): use mediaType instead of mimeType in sendMessage file parts#6

Open
saddlepaddle wants to merge 2 commits into
mainfrom
saddlepaddle/harness-file-support
Open

fix(harness): use mediaType instead of mimeType in sendMessage file parts#6
saddlepaddle wants to merge 2 commits into
mainfrom
saddlepaddle/harness-file-support

Conversation

@saddlepaddle
Copy link
Copy Markdown

@saddlepaddle saddlepaddle commented Mar 5, 2026

Description

Fixes a typo in the file part construction in harness.sendMessage() — the property mimeType should be mediaType.

This causes file parts to be routed through the V4 adapter instead of the V5 adapter, since the V5 FilePart type expects mediaType.

Introduced in mastra-ai#13574.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Checklist

  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works

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.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 5, 2026

Walkthrough

The 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 mimeType to mediaType to align with the expected field naming convention for newer implementations.

Changes

Cohort / File(s) Summary
File attachment property field rename
packages/core/src/harness/harness.ts
Changed file part property from mimeType to mediaType in sendMessage file handling logic.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the specific change made in the pull request: fixing the harness sendMessage file parts to use mediaType instead of mimeType.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch saddlepaddle/harness-file-support

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@saddlepaddle saddlepaddle changed the title feat(harness): add files support to sendMessage feat(harness): adjust mastracode api to match vercel api scheme for FileParts Mar 5, 2026
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

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.

Comment thread packages/core/src/harness/harness.ts Outdated
tracingContext?: TracingContext;
tracingOptions?: TracingOptions;
}): Promise<void> {
console.info(
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Mar 5, 2026

Choose a reason for hiding this comment

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

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>
Fix with Cubic

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5f60764 and 91fb64a.

📒 Files selected for processing (1)
  • packages/core/src/harness/harness.ts

Comment on lines 1239 to 1244
return {
type: 'file' as const,
data: f.data,
mimeType: f.mediaType,
mediaType: f.mediaType,
filename: f.filename,
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 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.

@saddlepaddle saddlepaddle changed the title feat(harness): adjust mastracode api to match vercel api scheme for FileParts fix(harness): use mediaType instead of mimeType in sendMessage file parts Mar 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant