fix(mindspace): map publication RPC errors to HTTP status codes

Return 404/401/403 from MindSpace RPC for known publication errors and
preserve error codes through the Portal remote adapter.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-07-05 19:44:58 +08:00
parent 85061dfa9f
commit 53eb0014ba
4 changed files with 130 additions and 12 deletions
+23
View File
@@ -133,3 +133,26 @@ test('createMindSpaceRemoteServerAdapter surfaces remote conversation package er
/conversationPackageRegistry\.readManifestForSession\(\) failed with 502: upstream manifest missing/,
);
});
test('createMindSpaceRemoteServerAdapter preserves publication error codes from rpc payload', async () => {
const adapter = createMindSpaceRemoteServerAdapter({
endpoint: 'https://mindspace.example.com/',
authToken: 'secret-token',
fetchFn: async () => ({
ok: false,
status: 404,
async text() {
return JSON.stringify({
message: '公开页面不存在',
code: 'publication_not_found',
});
},
}),
logger: { log() {}, warn() {}, error() {} },
});
await assert.rejects(
() => adapter.publicationService.resolvePublic('john', 'missing-page', null, null, {}),
(error) => error instanceof Error && error.code === 'publication_not_found',
);
});