Skip to content

sendgrid-go inbound.Parse fails with panic when Content-Type is text/html #28

@m-terel

Description

@m-terel

I've set up Inbound Email Parse Webhook. In the webhook I use https://github.com/sendgrid/sendgrid-go lib.

inbound.Parse method fails with a panic for some of the received HTTP requests. It fails when the Content-Type of the received HTTP request is "text/html; charset=utf-8". It works only for multipart content types.

address or nil pointer dereference

goroutine 67 [running]:
runtime/debug.Stack(0xc0003394b8, 0xb5c0c0, 0x1207480)
	/usr/local/go/src/runtime/debug/stack.go:24 +0x9f
github.com/GoogleCloudPlatform/functions-framework-go/funcframework.recoverPanicHTTP(0xd38be0, 0xc0002881c0, 0xc58b92, 0xe)
	/workspace/serverless_function_source_code/vendor/github.com/GoogleCloudPlatform/functions-framework-go/funcframework/framework.go:52 +0x76
panic(0xb5c0c0, 0x1207480)
	/usr/local/go/src/runtime/panic.go:965 +0x1b9
mime/multipart.(*Reader).nextPart(0x0, 0xc00068a300, 0xc0006748d5, 0x18, 0x0)
	/usr/local/go/src/mime/multipart/multipart.go:319 +0x37
mime/multipart.(*Reader).NextPart(...)
	/usr/local/go/src/mime/multipart/multipart.go:306
github.com/sendgrid/sendgrid-go/helpers/inbound.(*ParsedEmail).parseRawEmail(0xc00068a0c0, 0xc000674000, 0x82df, 0x7, 0x126ade0)
	/workspace/serverless_function_source_code/vendor/github.com/sendgrid/sendgrid-go/helpers/inbound/inbound.go:56 +0x375
github.com/sendgrid/sendgrid-go/helpers/inbound.(*ParsedEmail).parse(0xc00068a0c0, 0xc00068a0c0, 0xc0002f7380)
	/workspace/serverless_function_source_code/vendor/github.com/sendgrid/sendgrid-go/helpers/inbound/inbound.go:41 +0x134
github.com/sendgrid/sendgrid-go/helpers/inbound.Parse(0xc000306b00, 0x1, 0xc0002f7408, 0x419d01)
	/workspace/serverless_function_source_code/vendor/github.com/sendgrid/sendgrid-go/helpers/inbound/inbound.go:26 +0x9e
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions