feat(storage): improve storage connectivity error handling and multi-instance support

Enhance error messaging for storage connectivity issues by sanitizing raw errors to prevent leaking sensitive information. Introduce a new utility function for consistent error handling across storage backend operations. Additionally, implement logic to support multi-instance storage backends, allowing for more flexible workspace configurations and improved reporting of active storage providers.
This commit is contained in:
wizardchen
2026-07-15 14:36:26 +08:00
committed by lyingbug
parent 6349fff002
commit a8dea5f9a3
8 changed files with 208 additions and 42 deletions
@@ -35,7 +35,7 @@ func (s *StorageBackendService) Create(ctx context.Context, backend *types.Stora
return err
}
if err := s.Test(ctx, backend); err != nil {
return apperrors.NewBadRequestError("storage connection test failed").WithDetails(err.Error())
return apperrors.NewBadRequestError("storage connection test failed").WithDetails(secutils.SanitizeStorageConnectivityError(err))
}
backend.CreatedAt, backend.UpdatedAt = time.Now(), time.Now()
if err := s.repo.Create(ctx, backend); err != nil {
@@ -87,7 +87,7 @@ func (s *StorageBackendService) Update(ctx context.Context, incoming *types.Stor
return err
}
if err := s.Test(ctx, incoming); err != nil {
return apperrors.NewBadRequestError("storage connection test failed").WithDetails(err.Error())
return apperrors.NewBadRequestError("storage connection test failed").WithDetails(secutils.SanitizeStorageConnectivityError(err))
}
incoming.UpdatedAt = time.Now()
return s.repo.Update(ctx, incoming)