{"record":{"id":"0230b5ada888cb45","repo":"apache/pulsar","slug":"config-file-is-nil","errorCode":null,"errorMessage":"config file is nil.","messagePattern":"config file is nil\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pulsar-function-go/pf/instanceConf.go","lineNumber":158,"sourceCode":"\n\tif !instanceConf.funcDetails.AutoAck && //nolint:staticcheck\n\t\t(instanceConf.funcDetails.ProcessingGuarantees == pb.ProcessingGuarantees_ATMOST_ONCE ||\n\t\t\tinstanceConf.funcDetails.ProcessingGuarantees == pb.ProcessingGuarantees_ATLEAST_ONCE) {\n\t\tpanic(\"When Guarantees == \" + instanceConf.funcDetails.ProcessingGuarantees.String() +\n\t\t\t\", autoAck must be equal to true. If you want not to automatically ack, \" +\n\t\t\t\"please configure the processing guarantees as MANUAL.\" +\n\t\t\t\" This is a contradictory configuration, autoAck will be removed later.\" +\n\t\t\t\" Please refer to PIP: https://github.com/apache/pulsar/issues/15560\")\n\t}\n\n\treturn instanceConf\n}\n\nfunc newInstanceConf() *instanceConf {\n\tconfig := &conf.Conf{}\n\tcfg := config.GetConf()\n\tif cfg == nil {\n\t\tpanic(\"config file is nil.\")\n\t}\n\treturn newInstanceConfWithConf(cfg)\n}\n\nfunc (ic *instanceConf) getInstanceName() string {\n\treturn \"\" + fmt.Sprintf(\"%d\", ic.instanceID)\n}\n","sourceCodeStart":140,"sourceCodeEnd":166,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-function-go/pf/instanceConf.go#L140-L166","documentation":"newInstanceConf builds the Go function instance configuration from a YAML config file. If conf.GetConf() returns nil (viper failed to read/parse the config), the code panics with 'config file is nil.' because the instance cannot run without its configuration.","triggerScenarios":"Calling pf.NewFuncContext (which calls newInstanceConf) when the config file path is wrong, the file does not exist, it is malformed YAML, or the environment (e.g. kubeless/function-mesh injector) failed to mount it.","commonSituations":"Running a Go function locally without the config file that production injects (functions_instance_config.conf), bad func.yaml config path, missing --instance-conf argument, or a k8s ConfigMap/volume mount miss.","solutions":["Ensure the config file path passed to the instance exists and is valid YAML before starting the function","Verify environment variables/config injected by the runtime (e.g. conf file at /etc/pulsar/functions/config) are mounted","Add a pre-flight check: load conf.Conf{}.GetConf() yourself and log viper errors instead of hitting the panic","When running tests, construct the conf explicitly rather than relying on the default file lookup"],"exampleFix":"// before\nctx := pf.NewFuncContext() // panics: config file is nil.\n// after\nif cfg := (&conf.Conf{}).GetConf(); cfg == nil {\n    log.Fatal(\"instance config missing: pass a valid config file path\")\n}\nctx := pf.NewFuncContext()","handlingStrategy":"validation","validationCode":"cfg := (&conf.Conf{}).GetConf()\nif cfg == nil {\n    return fmt.Errorf(\"instance config file missing or invalid\")\n}","typeGuard":"func hasConfig() bool { return (&conf.Conf{}).GetConf() != nil }","tryCatchPattern":"// Go panics are not catchable idiomatic; pre-validate instead.\n// If necessary: defer func() { if r := recover(); r != nil { log.Fatalf(\"config load failed: %v\", r) } }()","preventionTips":["Always mount/provide the functions instance config file before launching","Validate the YAML parses locally with the same conf package before deploying","Log viper errors at startup to surface file/parse problems early"],"tags":["go","config","panic","startup"],"backgroundTag":"missing-config-file","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}