Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calls not being traced if validation fails #1078

Open
melkstam opened this issue Mar 11, 2024 · 0 comments
Open

Calls not being traced if validation fails #1078

melkstam opened this issue Mar 11, 2024 · 0 comments

Comments

@melkstam
Copy link
Contributor

We've had a few cases where traces for calls would not show up, neither locally, encore or our own cloud. To the best of our understanding, it happens when an internal parameter validation function returns an error.

Here is an example which reproduces the issue. When calling hello.World with failValidation: true, the following app does not gets any traced logged.

package hello

import (
	"context"

	"encore.dev/beta/errs"
)

type WorldParams struct {
	FailValidation bool `json:"failValidation"`
}

type WorldResponse struct {
	Message string `json:"message"`
}

//encore:api public
func World(ctx context.Context, in *WorldParams) (*WorldResponse, error) {

	err := WorldInteral(ctx, &WorldInternalParams{
		FailValidation: in.FailValidation,
	})
	if err != nil {
		return nil, err
	}

	return &WorldResponse{Message: "Hello, encore!"}, nil
}

type WorldInternalParams struct {
	FailValidation bool `json:"failValidation"`
}

func (p *WorldInternalParams) Validate() error {
	if p.FailValidation {
		return &errs.Error{Code: errs.InvalidArgument}
	}
	return nil
}

// encore:api private
func WorldInteral(ctx context.Context, in *WorldInternalParams) error {
	return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant