encoredev / encore

Development Platform for building robust type-safe distributed systems with declarative infrastructure

Home Page:https://encore.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

An unhandled panic occurred in the Encore compiler: runtime error: index out of range [3] with length 3

saujanreshmi opened this issue · comments

restoring build cache
no build cache found, skipping
── Internal compiler error ────────────────────────────────────────────[E0001]──

An unhandled panic occurred in the Encore compiler: runtime error: index out of
range [3] with length 3

This is a bug in Encore and should not have occurred. Please report this issue
to the Encore team either on Github at
https://github.com/encoredev/encore/issues/new and include this error.

╭─[Stack Trace]
├─▶ v2builder.BuilderImpl.Parse.func1.1 /encore-compiler/v2/v2builder/v2builder.go:47
├─▶ app.(*Desc).validateAPIs /encore-compiler/v2/app/validate_apis.go:76
├─▶ app.(*Desc).validate /encore-compiler/v2/app/validate.go:21
├─▶ app.ValidateAndDescribe /encore-compiler/v2/app/app.go:104
├─▶ v2builder.BuilderImpl.Parse.func1 /encore-compiler/v2/v2builder/v2builder.go:84
├─▶ etrace.Sync2[...] /encore-compiler/internal/etrace/etrace.go:20
╰─[... remaining frames omitted ...]

Thanks for the report @saujanreshmi! From the stack trace, it seems like the issue is most likely due to having defined path parameters in the path annotation, but not having a corresponding parameter on the function signature.

A correct signature might be:

//encore:api public method=POST path=/blog/:postID/comment
func AddComment(ctx context.Context, postID int, params *AddCommentParams) error

Notice the postID function parameter corresponding to the :postID path parameter.

I think if you fix that your code should work. If that's not the issue it would be great if you can share a reproducer.

Regardless, we'll fix the issue in the compiler so the error is reported correctly.

Hi @eandre , Code works fine locally for me, I am only getting this error in my deploys.

Screenshot 2023-06-12 at 8 51 21 am

This is now fixed (#763), thanks very much for reporting!