{"record":{"id":"6754f48abfdb5edf","repo":"gofr-dev/gofr","slug":"w-v-6754f4","errorCode":null,"errorMessage":"%w : %v","messagePattern":"%w : %v","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/gofr/http_server.go","lineNumber":152,"sourceCode":"func (s *httpServer) Shutdown(ctx context.Context) error {\n\ts.srvMu.Lock()\n\tsrv := s.srv\n\ts.srvMu.Unlock()\n\n\tif srv == nil {\n\t\treturn nil\n\t}\n\n\treturn ShutdownWithContext(ctx, func(ctx context.Context) error {\n\t\treturn srv.Shutdown(ctx)\n\t}, func() error {\n\t\treturn srv.Close()\n\t})\n}\n\nfunc validateCertificateAndKeyFiles(certificateFile, keyFile string) error {\n\tif _, err := os.Stat(certificateFile); os.IsNotExist(err) {\n\t\treturn fmt.Errorf(\"%w : %v\", errInvalidCertificateFile, certificateFile)\n\t}\n\n\tif _, err := os.Stat(keyFile); os.IsNotExist(err) {\n\t\treturn fmt.Errorf(\"%w : %v\", errInvalidKeyFile, keyFile)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":134,"sourceCodeEnd":161,"githubUrl":"https://github.com/gofr-dev/gofr/blob/187eb24962502e91f1fee856230670958b66e89c/pkg/gofr/http_server.go#L134-L161","documentation":"At pkg/gofr/http_server.go:152, validateCertificateAndKeyFiles returns fmt.Errorf(\"%w : %v\", errInvalidCertificateFile, certificateFile) when os.Stat on the certificate file reports it does not exist. The wrapped error preserves the sentinel for errors.Is checks while appending the offending path for diagnosis.","triggerScenarios":"os.Stat(certificateFile) returns an error satisfying os.IsNotExist during server startup (run() calls validateCertificateAndKeyFiles); the formatted error names the exact missing path.","commonSituations":"Deploying to a fresh environment where cert provisioning step was skipped; wrong working directory making relative paths invalid; config drift between environments (staging paths hardcoded in prod).","solutions":["Stat/ls the exact path printed in the error message to confirm it is missing","Correct the certificate path in config/env to an existing absolute path","Ensure cert provisioning (cert-manager, secret mount, CI step) runs before the service starts","Run the service from a working directory where relative cert paths resolve, or switch to absolute paths"],"exampleFix":"// before\ncertFile := \"certs/server.crt\" // relative; CWD differs in prod\n// after\ncertFile := \"/etc/gofr/tls/server.crt\" // absolute, verified with os.Stat\nif _, err := os.Stat(certFile); err != nil { log.Fatalf(\"missing cert: %v\", err) }","handlingStrategy":"validation","validationCode":"if _, err := os.Stat(certPath); os.IsNotExist(err) {\n    return fmt.Errorf(\"certificate not found at %s\", certPath)\n}\nif _, err := os.Stat(keyPath); os.IsNotExist(err) {\n    return fmt.Errorf(\"key not found at %s\", keyPath)\n}","typeGuard":"func isCertFileMissing(err error) bool {\n    return errors.Is(err, errInvalidCertificateFile)\n}","tryCatchPattern":"if err := validateCertificateAndKeyFiles(cert, key); err != nil {\n    if errors.Is(err, errInvalidCertificateFile) {\n        // message suffix holds the offending path\n        log.Fatalf(\"certificate file missing: %v\", err)\n    }\n    return err\n}","preventionTips":["Call validateCertificateAndKeyFiles (or your own Stat check) before run()","Prefer absolute cert paths; log os.Getwd() to debug relative paths","Gate deployment on cert provisioning jobs completing successfully","Keep per-environment TLS paths in config, not hardcoded"],"tags":["tls","certificate","startup","configuration"],"backgroundTag":"tls-certificate-file-missing","analyzedSha":"187eb24962502e91f1fee856230670958b66e89c","analyzedAt":"2026-09-01T20:34:54.554Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}