Skip to content

Commit

Permalink
no stack should be empty list instead of nil
Browse files Browse the repository at this point in the history
  • Loading branch information
bmoffatt committed Jan 24, 2024
1 parent 1aaad14 commit b96de21
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lambda/invoke_loop.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,17 @@ func makeXRayError(invokeResponseError *messages.InvokeResponse_Error) *xrayErro
paths = append(paths, path)
}
cwd, _ := os.Getwd()
exceptions := []xrayException{{
Type: invokeResponseError.Type,
Message: invokeResponseError.Message,
Stack: invokeResponseError.StackTrace,
}}
if exceptions[0].Stack == nil {
exceptions[0].Stack = []*messages.InvokeResponse_Error_StackFrame{}
}
return &xrayError{
WorkingDirectory: cwd,
Paths: paths,
Exceptions: []xrayException{{
Type: invokeResponseError.Type,
Message: invokeResponseError.Message,
Stack: invokeResponseError.StackTrace,
}},
Exceptions: exceptions,
}
}
27 changes: 27 additions & 0 deletions lambda/invoke_loop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func TestCustomErrorMarshaling(t *testing.T) {

func TestXRayCausePlumbing(t *testing.T) {
errors := []error{
errors.New("barf"),
messages.InvokeResponse_Error{
Type: "yoloError",
Message: "hello yolo",
Expand All @@ -100,9 +101,24 @@ func TestXRayCausePlumbing(t *testing.T) {
{Label: "hi", Path: "hello/hello", Line: 12},
},
},
messages.InvokeResponse_Error{
Type: "yoloError",
Message: "hello yolo",
StackTrace: []*messages.InvokeResponse_Error_StackFrame{
},
},
}
wd, _ := os.Getwd()
expected := []string{
`{
"working_directory":"` + wd + `",
"paths": [],
"exceptions": [{
"type": "errorString",
"message": "barf",
"stack": []
}]
}`,
`{
"working_directory":"` + wd + `",
"paths": ["yolo", "hello/hello"],
Expand All @@ -115,6 +131,17 @@ func TestXRayCausePlumbing(t *testing.T) {
]
}]
}`,
`{
"working_directory":"` + wd + `",
"paths": [],
"exceptions": [{
"type": "yoloError",
"message": "hello yolo",
"stack": [
]
}]
}`,

}
require.Equal(t, len(errors), len(expected))
ts, record := runtimeAPIServer(``, len(errors))
Expand Down

0 comments on commit b96de21

Please sign in to comment.