{"record":{"id":"d130b5a93cdc0e91","repo":"temporalio/temporal","slug":"panic-err-d130b5","errorCode":null,"errorMessage":"panic(err)","messagePattern":"panic\\(err\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/testing/fakedata/fakedata.go","lineNumber":18,"sourceCode":"// Package fakedata provides utilities for generating random data for testing. We recently migrated from gofakeit to\n// go-faker. This was to avoid the problem described here: https://github.com/brianvoe/gofakeit/issues/281#issue-2071796056.\n// To make such migrations easier in the future, and to ensure that we use [faker.SetIgnoreInterface] before any\n// invocation, we created this package.\npackage fakedata\n\nimport (\n\t\"github.com/go-faker/faker/v4\"\n)\n\nfunc init() {\n\t// We need this option to prevent faker.FakeData from returning an error for any struct that has an interface{} field.\n\tfaker.SetIgnoreInterface(true)\n\t// We need this option to prevent faker from taking a long time while generating random data for structs that have\n\t// map or slice fields. This is especially relevant for persistence.ShardInfo, which takes about 1s without this\n\t// option, but only ~100µs with it.\n\tif err := faker.SetRandomMapAndSliceMaxSize(2); err != nil {\n\t\tpanic(err)\n\t}\n}\n\n// FakeStruct generates random data for the given struct pointer. Example usage:\n//\n//\tvar shardInfo persistencespb.ShardInfo\n//\t_ = fakedata.FakeStruct(&shardInfo)\nfunc FakeStruct(a any) error {\n\treturn faker.FakeData(a)\n}\n","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/common/testing/fakedata/fakedata.go#L1-L29","documentation":"fakedata.go's package init configures the go-faker library once for the whole test process: it enables ignoring interface{} fields and caps random map/slice size. If either configuration call returns an error, the init function panics with panic(err), meaning the test binary cannot even start because faker's global config failed.","triggerScenarios":"Running any test binary importing common/testing/fakedata where faker.SetRandomMapAndSliceMaxSize(2) or faker.SetIgnoreInterface(true) returns an error — e.g. an upstream faker version change that altered these APIs' signatures/behavior.","commonSituations":"Upgrading go-faker to a version where SetRandomMapAndSliceMaxSize validates its argument or returns an error under new conditions; vendoring conflicts causing an unexpected faker implementation to be linked.","solutions":["Check the go-faker version in go.mod and confirm SetRandomMapAndSliceMaxSize/SetIgnoreInterface exist with the expected signatures; run `go mod tidy` and rebuild.","Upgrade or pin go-faker to the version compatible with temporal's fakedata package.","Inspect the underlying err value (change the panic to log it) to see the exact faker configuration failure."],"exampleFix":"// before\nif err := faker.SetRandomMapAndSliceMaxSize(2); err != nil {\n\tpanic(err)\n}\n// after\nif err := faker.SetRandomMapAndSliceMaxSize(2); err != nil {\n\tlogger.Fatal(\"failed to configure faker\", \"error\", err) // or investigate the error\n}","handlingStrategy":"validation","validationCode":"if err := faker.SetRandomMapAndSliceMaxSize(2); err != nil {\n\tt.Fatalf(\"faker config failed: %v\", err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin the go-faker version in go.mod and review its API when upgrading.","Keep fakedata config in one package init and add a smoke test that imports it."],"tags":["testing","test-data","panic","initialization"],"backgroundTag":"library-initialization-panic","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}