Skip to content

Commit aa4a5ae

Browse files
abhiaiyer91Mastra Code (anthropic/claude-opus-4-6)
andauthored
fix(core): fix build error in embedding router doEmbed return type (#13461)
## Summary `pnpm build:core` fails on `main` with: ``` TS2353: Object literal may only specify known properties, and 'warnings' does not exist in type ... ``` This was introduced by #13369 which added a `warnings` array to the `doEmbed()` return for AI SDK v6 compatibility. The runtime behavior is correct, but the TypeScript return type (`EmbeddingModelV2.doEmbed`) does not include `warnings`, causing a build error. ## Fix Added a type assertion (`as Awaited<ReturnType<...>>`) so TypeScript accepts the return value while preserving the runtime `warnings` array that AI SDK v6 needs. ## Test plan - `pnpm build:core` — passes (previously failed) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Fixed a build error in the embedding model router that prevented successful compilation. The issue involved inconsistent handling of warnings in the return type, causing type validation failures. This patch ensures proper type alignment and consistency, restoring the ability to build the package successfully. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: Mastra Code (anthropic/claude-opus-4-6) <noreply@mastra.ai>
1 parent 861f111 commit aa4a5ae

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@mastra/core': patch
3+
---
4+
5+
Fixed build error in `ModelRouterEmbeddingModel.doEmbed()` caused by `warnings` not existing on the return type.

packages/core/src/llm/model/embedding-router.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,9 @@ export class ModelRouterEmbeddingModel<VALUE extends string = string> implements
219219
args: Parameters<EmbeddingModelV2<VALUE>['doEmbed']>[0],
220220
): Promise<Awaited<ReturnType<EmbeddingModelV2<VALUE>['doEmbed']>>> {
221221
const result = await this.providerModel.doEmbed(args);
222+
// Ensure warnings is always an array — AI SDK v6's embedMany spreads
223+
// result.warnings and crashes if it's undefined.
222224
const warnings = (result as { warnings?: unknown[] }).warnings ?? [];
223-
return { ...result, warnings };
225+
return { ...result, warnings } as Awaited<ReturnType<EmbeddingModelV2<VALUE>['doEmbed']>>;
224226
}
225227
}

0 commit comments

Comments
 (0)