Skip to content

Commit

Permalink
fix: missing send error field when an error response exists (#1217)
Browse files Browse the repository at this point in the history
* fix: missing send error field when an error response is exist

* fix: send error to /event

* fix test

---------

Co-authored-by: Kevin Hermawan <[email protected]>
Co-authored-by: Mochamad Noor Syamsu <[email protected]>
  • Loading branch information
3 people authored Dec 22, 2023
1 parent ed79689 commit 8688b32
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/components/probe/prober/http/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,13 @@ export async function httpRequest({
// 400, 500 get here
if (error?.response) {
return {
data: error?.response?.data,
body: error?.response?.data,
status: error?.response?.status as number,
data: '',
body: '',
status: error?.response?.status,
headers: error?.response?.headers,
responseTime,
result: probeRequestResult.success,
error: error?.response?.data,
}
}

Expand All @@ -208,13 +209,13 @@ export async function httpRequest({
const { status, description } = getErrorStatusWithExplanation(error)

return {
data: description,
data: '',
body: '',
status,
headers: '',
responseTime,
result: probeRequestResult.failed,
error: (error as AxiosError).message,
error: description,
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/symon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ export default class SymonClient {
validation,
alertId,
}: NotificationEvent) {
const { data, headers, responseTime, status } = validation.response
const { data, headers, responseTime, status, error } = validation.response

this.httpClient
.post('/events', {
monikaId: this.monikaId,
Expand All @@ -303,6 +304,7 @@ export default class SymonClient {
size: headers['content-length'],
status, // status is http status code
time: responseTime,
error,
},
})
.then(() => {
Expand Down

0 comments on commit 8688b32

Please sign in to comment.