fix(openai-shim): restore provider coverage and array content guard

Keep relocated openaiShim suite tests in test:provider, and reject
non-object array content parts the same way the inline converter did.
This commit is contained in:
jatmn
2026-07-26 22:13:52 -07:00
parent 8149f093ea
commit 1ed6ccd671
3 changed files with 16 additions and 3 deletions
+1 -1
View File
@@ -68,7 +68,7 @@
"install:verify": "bun run scripts/verify-clean-install.ts",
"install:verify:published": "bun run scripts/verify-clean-install.ts --published",
"build:verified": "bun run build && bun run verify:privacy",
"test:provider": "bun test --feature=UNATTENDED_RETRY --max-concurrency=1 src/services/api/*.test.ts src/utils/context.test.ts",
"test:provider": "bun test --feature=UNATTENDED_RETRY --max-concurrency=1 src/services/api/*.test.ts src/services/api/openaiShim/*.test.ts src/utils/context.test.ts",
"doctor:runtime": "bun run scripts/system-check.ts",
"doctor:runtime:json": "bun run scripts/system-check.ts --json",
"doctor:report": "bun run scripts/system-check.ts --out reports/doctor-runtime.json",
@@ -203,12 +203,17 @@ test('preserves structured Gemini signatures and safety terminal responses', ()
})
test('normalizes array content and length stop reasons', () => {
const functionPart = Object.assign(() => {}, {
type: 'text' as const,
text: 'ignored-fn',
})
const message = convert({
choices: [{
message: {
content: [
{ type: 'text', text: 'first' },
{ type: 'image' },
functionPart,
{ type: 'text', text: 'second' },
],
},
@@ -69,8 +69,16 @@ export function convertNonStreamingResponseToAnthropicMessage(
? choice.message.content : null
if (typeof rawContent === 'string' && rawContent) appendTextOrRecoveredToolCalls(rawContent)
else if (Array.isArray(rawContent)) {
const text = rawContent.filter(part => part?.type === 'text' && typeof part.text === 'string')
.map(part => part.text!).join('\n')
const text = rawContent
.filter(
part =>
part &&
typeof part === 'object' &&
part.type === 'text' &&
typeof part.text === 'string',
)
.map(part => part.text!)
.join('\n')
if (text) appendTextOrRecoveredToolCalls(text)
}