{"record":{"id":"d979973a56d09e82","repo":"gofr-dev/gofr","slug":"status-down-d97997","errorCode":null,"errorMessage":"status down","messagePattern":"status down","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/gofr/datasource/kv-store/nats/nats.go","lineNumber":15,"sourceCode":"package nats\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/nats-io/nats.go\"\n\t\"go.opentelemetry.io/otel/attribute\"\n\t\"go.opentelemetry.io/otel/trace\"\n)\n\nvar (\n\terrStatusDown  = errors.New(\"status down\")\n\terrKeyNotFound = errors.New(\"key not found\")\n)\n\ntype Configs struct {\n\tServer string\n\tBucket string\n}\n\ntype jetStream struct {\n\tnats.JetStreamContext\n}\n\nfunc (j jetStream) AccountInfo() (*nats.AccountInfo, error) {\n\treturn j.JetStreamContext.AccountInfo()\n}\n\ntype Client struct {\n\tconn    *nats.Conn","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/gofr-dev/gofr/blob/187eb24962502e91f1fee856230670958b66e89c/pkg/gofr/datasource/kv-store/nats/nats.go#L1-L33","documentation":"In the NATS KV-store client, errStatusDown ('status down') is the sentinel returned by HealthCheck when the JetStream key-value bucket or the NATS connection is unavailable. It reports the datasource as unhealthy so monitoring can flag it.","triggerScenarios":"HealthCheck called while the NATS server is unreachable, the client was never connected, the configured Bucket does not exist in JetStream, or the JetStream stream backing the bucket was deleted.","commonSituations":"NATS server down or wrong Server URL/port, bucket name typo, JetStream disabled on the server, bucket deleted by max-age limits or manually.","solutions":["Verify Configs.Server points to a reachable NATS server (nats://host:4222)","Confirm the JetStream bucket exists: nats kv info <bucket>, or create it before use","Reconnect/retry; inspect the wrapped cause for the underlying NATS error","Check the server has JetStream enabled (--js flag)"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// pre-flight connectivity probe\nnc, err := nats.Connect(cfg.Server, nats.Timeout(3*time.Second))\nif err != nil { return fmt.Errorf(\"nats unreachable: %w\", err) }\njs, _ := nc.JetStream()\nif _, err := js.KeyValue(cfg.Bucket); err != nil { return fmt.Errorf(\"bucket %q missing: %w\", cfg.Bucket, err) }","typeGuard":"func IsStatusDown(err error) bool { return errors.Is(err, natskv.ErrStatusDown) }","tryCatchPattern":"if err := store.HealthCheck(ctx); err != nil {\n    if errors.Is(err, natskv.ErrStatusDown) {\n        return retry.WithBackoff(store.HealthCheck, 5*time.Second)\n    }\n    return err\n}","preventionTips":["Gate traffic on a passing HealthCheck","Create/verify the KV bucket during app startup","Ensure JetStream is enabled on the NATS server","Monitor connection status and reconnect events"],"tags":["nats","jetstream","health-check","connectivity"],"backgroundTag":"service-health-check-failed","analyzedSha":"187eb24962502e91f1fee856230670958b66e89c","analyzedAt":"2026-09-01T20:34:54.554Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}