This is an automated email from the ASF dual-hosted git repository.

warren pushed a commit to branch fix/helpers-panic-to-error
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit 9731255b2f1cf6260c6cdd065dd727ef8fdfdb82
Author: warren <[email protected]>
AuthorDate: Mon Mar 16 00:17:11 2026 +0800

    fix: replace panics with error returns in helper packages
    
    In TxHelper.LockTablesTimeout, return the lock error instead of panicking
    so callers can handle it gracefully. In ScopeSrvHelper.getAffectedTables,
    return an error instead of panicking when plugin doesn't implement
    PluginModel interface.
---
 backend/helpers/dbhelper/txhelper.go              | 2 +-
 backend/helpers/srvhelper/scope_service_helper.go | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/backend/helpers/dbhelper/txhelper.go 
b/backend/helpers/dbhelper/txhelper.go
index c9101f4ec..e0a073dc7 100644
--- a/backend/helpers/dbhelper/txhelper.go
+++ b/backend/helpers/dbhelper/txhelper.go
@@ -57,7 +57,7 @@ func (l *TxHelper[E]) LockTablesTimeout(timeout 
time.Duration, lockTables dal.Lo
        select {
        case err := <-c:
                if err != nil {
-                       panic(err)
+                       return err
                }
        case <-time.After(timeout):
                return errors.Timeout.New("lock tables timeout: " + 
fmt.Sprintf("%v", lockTables))
diff --git a/backend/helpers/srvhelper/scope_service_helper.go 
b/backend/helpers/srvhelper/scope_service_helper.go
index 544536f01..a05e94d20 100644
--- a/backend/helpers/srvhelper/scope_service_helper.go
+++ b/backend/helpers/srvhelper/scope_service_helper.go
@@ -270,7 +270,7 @@ func (scopeSrv *ScopeSrvHelper[C, S, SC]) 
getAffectedTables() ([]string, errors.
        }
        pluginModel, ok := meta.(plugin.PluginModel)
        if !ok {
-               panic(errors.Default.New(fmt.Sprintf("plugin \"%s\" does not 
implement listing its tables", scopeSrv.pluginName)))
+               return nil, errors.Default.New(fmt.Sprintf("plugin \"%s\" does 
not implement listing its tables", scopeSrv.pluginName))
        }
        // Unfortunately, can't cache the tables because Python creates some 
tables on a per-demand basis, so such a cache would possibly get outdated.
        // It's a rare scenario in practice, but might as well play it safe and 
sacrifice some performance here

Reply via email to