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:
@@ -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',
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user