Hi Michael, Thanks for replying, we did identify this as well. Inside `findFunction` it first tries to see if the `function` is a user defined, and if yes returns that. If not then it tries to find it within `builtIn` func map. The `builtIn` funcMap is populated using `sync.Once` and we can clearly see that `len` is a built in function. The thing that stumps me the most is that, before the error started appearing , the same code was working fine on the same pod -> ie it was able to find `len` template function before.
On Thursday, October 20, 2022 at 7:09:29 PM UTC+5:30 michael...@gmail.com wrote: > I did a quick search for "is not a defined function". That message > appears once in https://go.dev/src/text/template/exec.go. It's triggered > when findFunction() fails while executing a template. > > Hope that's of some use. > > > On Wednesday, October 19, 2022 at 8:20:46 AM UTC-4 rit...@ext.dunzo.in > wrote: > >> >> We are facing a strange issue within one of our services where randomly >> one of the docker containers in production out of (N, N>50) starts >> randomly failing on an API while trying to execute a golang template with >> an error *"Err: template: <template name>: executing \"<template name>\" >> at len: \"len\" is not a defined function". *`len` is a builtin >> function within golang so am stumped why this error comes. Some more >> context >> >> >> - *Golang Version: 1.15* >> - The same Pod was serving this API and executing the template >> correctly before this issue started coming >> - Parsing the template works fine, only executing fails. We are >> parsing and executing in sequence. >> - After this error was encountered first, all subsequent API calls to >> the same container failed with the same error >> - The same API on all other containers works perfectly fine. We >> removed the container from serving prod traffic, and this issue >> disappeared >> - This is the second time the issue is happening, first time we >> restarted the container and hence weren't able to debug much >> - Binary is stripped of symbol tables and ptrace is not enabled >> >> We have the container running (not serving prod traffic) so if there are >> any hints on how to debug this issue would appreciate. >> > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/d2940ae3-caf9-4502-8b55-e3a3e7734b9dn%40googlegroups.com.