Admiral-Piett / goaws

AWS (SQS/SNS) Clone for Development testing
MIT License
779 stars 144 forks source link

SQS DeleteMessageBatch runtime error: slice bounds out of range #171

Closed Iodine- closed 5 years ago

Iodine- commented 6 years ago

goaws is throwing an error when attempting to batch delete.

When using the javascript AWS-SDK (aws-sdk@2.268.1), and invoking sqs.deleteMessageBatch() against goaws running in docker - goaws throws an error:

2018/08/01 14:41:39 http: panic serving 172.19.0.1:59706: runtime error: slice bounds out of range
goroutine 29 [running]:
net/http.(*conn).serve.func1(0xc4200972c0)
    /usr/local/go/src/net/http/server.go:1726 +0xd0
panic(0x6fb2c0, 0x90a330)
    /usr/local/go/src/runtime/panic.go:502 +0x229
github.com/p4tin/goaws/app/gosqs.DeleteMessageBatch(0x79e8c0, 0xc4201842a0, 0xc420133300)
    /go/src/github.com/p4tin/goaws/app/gosqs/gosqs.go:579 +0x14a8
net/http.HandlerFunc.ServeHTTP(0x773e80, 0x79e8c0, 0xc4201842a0, 0xc420133300)
    /usr/local/go/src/net/http/server.go:1947 +0x44
github.com/p4tin/goaws/app/router.actionHandler(0x79e8c0, 0xc4201842a0, 0xc420133300)
    /go/src/github.com/p4tin/goaws/app/router/router.go:62 +0xb5
net/http.HandlerFunc.ServeHTTP(0x773ee0, 0x79e8c0, 0xc4201842a0, 0xc420133300)
    /usr/local/go/src/net/http/server.go:1947 +0x44
github.com/p4tin/goaws/vendor/github.com/gorilla/mux.(*Router).ServeHTTP(0xc4200953e0, 0x79e8c0, 0xc4201842a0, 0xc420133300)
    /go/src/github.com/p4tin/goaws/vendor/github.com/gorilla/mux/mux.go:150 +0xed
net/http.serverHandler.ServeHTTP(0xc42007de10, 0x79e8c0, 0xc4201842a0, 0xc420133100)
    /usr/local/go/src/net/http/server.go:2694 +0xbc
net/http.(*conn).serve(0xc4200972c0, 0x79ebc0, 0xc42008b0c0)
    /usr/local/go/src/net/http/server.go:1830 +0x651
created by net/http.(*Server).Serve
    /usr/local/go/src/net/http/server.go:2795 +0x27b

This appears to only happen when long polling the queue for messages, and then batch deleting the messages. Only occurs when there is >1 message returned from the receiveMessage() call (aka - deleteMessageBatch() works fine if there is only message to delete it seems)

I considered it may be an implementation issue on my side, however; the code works as expected against live AWS SQS. Which leads me to believe it is an issue with gosqs

notes

forrest-ua commented 5 years ago

Solution is here https://github.com/p4tin/goaws/pull/174