Skip to content

Commit f43350e

Browse files
fix: 修复 4 个测试失败(路径规范化、SDK 签名变更、空消息防护)
- projectContext.test.ts: 使用 realpathSync 处理 macOS /var→/private/var 符号链接 - bedrockClient.test.ts: 适配 Bedrock SDK v0.80 Bearer 认证(原 AWS4-HMAC-SHA256) - bridge.ts: forwardSessionUpdates 添加 null guard 防止空消息导致 TypeError Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 23fcbf9 commit f43350e

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

src/services/acp/bridge.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,8 @@ export async function forwardSessionUpdates(
587587
if (nextResult.done || abortSignal.aborted) break
588588
const msg = nextResult.value
589589

590+
if (msg == null) continue
591+
590592
const type = msg.type as string
591593

592594
switch (type) {

src/services/api/__tests__/bedrockClient.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,12 @@ describe('BedrockClient.buildRequest body.anthropic_beta cleanup', () => {
111111
const c = get()
112112
expect(c).not.toBeNull()
113113
expect(c!.headers.authorization).toBeDefined()
114-
expect(c!.headers.authorization.startsWith('AWS4-HMAC-SHA256')).toBe(true)
114+
// SDK >= 0.80 uses Bearer auth; older versions used AWS4-HMAC-SHA256 SigV4.
115+
// Either way the header must be present (i.e. signing was not broken).
116+
expect(
117+
c!.headers.authorization!.startsWith('AWS4-HMAC-SHA256') ||
118+
c!.headers.authorization!.startsWith('Bearer '),
119+
).toBe(true)
115120
})
116121

117122
test('FIX does not disturb requests that never had anthropic_beta', async () => {

src/services/skillLearning/__tests__/projectContext.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { afterAll, beforeEach, describe, expect, test } from 'bun:test'
2-
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync } from 'fs'
2+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync } from 'fs'
33
import { tmpdir } from 'os'
44
import { join } from 'path'
55
import { execFileSync } from 'child_process'
@@ -56,7 +56,7 @@ describe('resolveProjectContext', () => {
5656

5757
expect(context.source).toBe('claude_project_dir')
5858
expect(context.scope).toBe('project')
59-
expect(context.projectRoot).toBe(projectDir)
59+
expect(context.projectRoot).toBe(realpathSync(projectDir))
6060
expect(context.projectName).toBe(lastPathSegment(projectDir))
6161
expect(context.storageDir).toContain(context.projectId)
6262

@@ -99,7 +99,7 @@ describe('resolveProjectContext', () => {
9999

100100
expect(context.source).toBe('git_root')
101101
expect(context.scope).toBe('project')
102-
expect(context.projectRoot).toBe(repo)
102+
expect(context.projectRoot).toBe(realpathSync(repo))
103103
expect(context.projectName).toBe(lastPathSegment(repo))
104104
})
105105

0 commit comments

Comments
 (0)