Skip to content

Using Param() to map path parameters to attributes results in a runtime error #3462

Open
@Makirchn

Description

Hi, I'm new to goa and I want to map a path param e.g. product_id to a payload attribute id.

My design:

Service:

var _ = Service("products", func() {
	Description("The product service provides an API for managing products.")
	HTTP(func() {
		Path("/products")
	})

	// update product by id
	Method("update by id", func() {
		Payload(UpdateProductPayload)
		Result(UpdateProductPayload, func() {
			View("default")
		})
		Error("no_criteria", String, "Missing criteria")
		Error("no_match", String, "No product found with specified id")
		HTTP(func() {
			POST("/{product_id}")
			Param("product_id:id")
			Response(StatusOK)
			Response("no_criteria", StatusBadRequest)
			Response("no_match", StatusNotFound)
		})
	})
})

Payload Model:

var UpdateProductPayload = Type("UpdateProductPayload", func() {
	Attribute("id", String, "Product ID", func() {
		Example("83d83ec2-d2ca-49ff-bbea-b92b5c3be202")
	})
	Attribute("name", String, "Product Name", func() {
		Example("Apple")
	})
})

Generating the code results in:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x60 pc=0x1023a3028]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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