mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-08 22:39:36 +08:00
fix(agent): add response validation for ID mismatches
Add checks to ensure response IDs match expected values in agent API calls
This commit is contained in:
parent
4c4039283f
commit
02d2838424
@ -104,6 +104,9 @@ export class AgentApiClient {
|
||||
try {
|
||||
const response = await this.axios.get(url)
|
||||
const data = GetAgentResponseSchema.parse(response.data)
|
||||
if (data.id !== id) {
|
||||
throw new Error('Agent ID mismatch in response')
|
||||
}
|
||||
return data
|
||||
} catch (error) {
|
||||
throw processError(error, 'Failed to get agent.')
|
||||
@ -125,6 +128,9 @@ export class AgentApiClient {
|
||||
const payload = form satisfies UpdateAgentRequest
|
||||
const response = await this.axios.patch(url, payload)
|
||||
const data = UpdateAgentResponseSchema.parse(response.data)
|
||||
if (data.id !== form.id) {
|
||||
throw new Error('Agent ID mismatch in response')
|
||||
}
|
||||
return data
|
||||
} catch (error) {
|
||||
throw processError(error, 'Failed to updateAgent.')
|
||||
@ -162,6 +168,9 @@ export class AgentApiClient {
|
||||
try {
|
||||
const response = await this.axios.get(url)
|
||||
const data = GetAgentSessionResponseSchema.parse(response.data)
|
||||
if (sessionId !== data.id) {
|
||||
throw new Error('Session ID mismatch in response')
|
||||
}
|
||||
return data
|
||||
} catch (error) {
|
||||
throw processError(error, 'Failed to get session.')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user