From bcafd97e310c6616d655d00f0b01abbd0a9f9144 Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Thu, 2 Oct 2025 17:46:53 +0200 Subject: [PATCH] Catch bucket not found error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jörn Dreyer Signed-off-by: Christian Richter --- services/graph/pkg/command/server.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/services/graph/pkg/command/server.go b/services/graph/pkg/command/server.go index 9ab22e66c1..6d4e8b7019 100644 --- a/services/graph/pkg/command/server.go +++ b/services/graph/pkg/command/server.go @@ -16,6 +16,7 @@ import ( "github.com/opencloud-eu/opencloud/services/graph/pkg/metrics" "github.com/opencloud-eu/opencloud/services/graph/pkg/server/debug" "github.com/opencloud-eu/opencloud/services/graph/pkg/server/http" + "github.com/pkg/errors" "github.com/urfave/cli/v2" ) @@ -61,7 +62,16 @@ func Server(cfg *config.Config) *cli.Command { kv, err := js.KeyValue(cfg.Store.Database) if err != nil { - return err + if !errors.Is(err, nats.ErrBucketNotFound) { + return errors.Wrapf(err, "Failed to get bucket (%s)", cfg.Store.Database) + } + + kv, err = js.CreateKeyValue(&nats.KeyValueConfig{ + Bucket: cfg.Store.Database, + }) + if err != nil { + return errors.Wrapf(err, "Failed to create bucket (%s)", cfg.Store.Database) + } } if err != nil { return err