livebud / livebud/bud

Can't have a custom type be the input to a controller action

Open
#260 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
5.6k
Forks
175
PR merge metrics
No merged PRs in 30d

Description

With the following controller:

```go
package route171

import (
"errors"
"strings"
)

type Controller struct {
// Dependencies...
}

type Email string

func (email Email) Validate() error {
if !strings.Contains(string(email), "@") {
return errors.New("Not a valid email.")
}
return nil
}

func (c *Controller) Index(email Email) []string {
return []string{}
}
```

There is the following error:

```
genfs: error generating "bud/internal/app/controller/controller.go". controller: unable to load: controller: unable to find param definition for Email. parser: unable to find declaration for "Email" in "route171"
exit status 1
```

This came up when I was working on issue #171

I'll take a look at what is going on, but I wanted to put this issue in for tracking it since it's separate.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the controller parameter parsing path that produces the reported "unable to find param definition" error when processing controller.go. Reproduce the issue with the Email type and Index action shown above, then verify that a named custom type can be accepted as an action input without the parser error.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.