From c0da31945e95c0b0cca42c0e1a3037cb06356006 Mon Sep 17 00:00:00 2001 From: Tomas Dvorak Date: Sat, 19 Sep 2026 07:55:12 +0200 Subject: [PATCH] fix: correct two latent defects found in code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - migrator/share.go called tx.Rollback() on a possibly-nil tx inside the Tx() error branch — a nil-pointer panic on the failure path. - migration.go computed requiredVersion.Compare(requiredVersion), an always-false self-comparison that silently broke max-version tracking. - error message typo: 'ailed to decode' -> 'failed to decode'. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- application/migrator/share.go | 1 - inventory/file.go | 2 +- inventory/migration.go | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/application/migrator/share.go b/application/migrator/share.go index 8e5900d3..8fba330e 100644 --- a/application/migrator/share.go +++ b/application/migrator/share.go @@ -36,7 +36,6 @@ func (m *Migrator) migrateShare() error { tx, err := m.v4client.Tx(ctx) if err != nil { - _ = tx.Rollback() return fmt.Errorf("failed to start transaction: %w", err) } diff --git a/inventory/file.go b/inventory/file.go index a698f3c9..5f1abfde 100644 --- a/inventory/file.go +++ b/inventory/file.go @@ -417,7 +417,7 @@ func (f *fileClient) CreateDirectLink(ctx context.Context, file int, name string func (f *fileClient) GetByHashID(ctx context.Context, hashID string) (*ent.File, error) { id, err := f.hasher.Decode(hashID, hashid.FileID) if err != nil { - return nil, fmt.Errorf("ailed to decode hash id %q: %w", hashID, err) + return nil, fmt.Errorf("failed to decode hash id %q: %w", hashID, err) } return withFileEagerLoading(ctx, f.client.File.Query().Where(file.ID(id))).First(ctx) diff --git a/inventory/migration.go b/inventory/migration.go index 2734b3c1..a03c254c 100644 --- a/inventory/migration.go +++ b/inventory/migration.go @@ -826,7 +826,7 @@ func applyPatches(l logging.Logger, client *ent.Client, ctx context.Context, req return fmt.Errorf("failed to parse required version %s: %w", requiredDbVersion, err) } - if latestAppliedVersion == nil || requiredVersion.Compare(requiredVersion) > 0 { + if latestAppliedVersion == nil || requiredVersion.Compare(latestAppliedVersion) > 0 { latestAppliedVersion = requiredVersion }