Skip to content

fix(auth,config,db): guard nil pointers causing server panics - #4146

Draft
cursor[bot] wants to merge 3 commits into
developfrom
cursor/critical-bug-investigation-7680
Draft

fix(auth,config,db): guard nil pointers causing server panics#4146
cursor[bot] wants to merge 3 commits into
developfrom
cursor/critical-bug-investigation-7680

Conversation

@cursor

@cursor cursor Bot commented Aug 15, 2026

Copy link
Copy Markdown

Summary

Rebases and consolidates carryover critical panic fixes onto current develop. Supersedes conflicting PR #4096 and includes the migration rollback fix from PR #4103.

Bugs fixed

1. OIDC UserInfo nil dereference (api/login.go)

Impact: Server panic during OIDC login when the provider returns no id_token and the UserInfo endpoint fails.
Root cause: userInfo.Profile was read outside the err == nil block.
Fix: Extract oidcClaimsFromUserInfo that returns early on UserInfo error.

2. Nil Runners config panic (util/config.go, api/admin_info.go)

Impact: Server panic on admin info or runner registration when runners config section is omitted.
Root cause: conf.Runners accessed without nil guard.
Fix: Nil-safe helpers IsUseRemoteRunner, GetRunnerRegistrationToken, DefaultGlobalRunnersMode.

3. SqlDb Close panic (db/sql/SqlDb.go)

Impact: Panic when closing a DB connection that was never opened.
Root cause: Checked d.sql.Db but not d.sql itself.
Fix: Guard d.sql == nil before accessing d.sql.Db.

4. Migration rollback panic (db/sql/migration.go)

Impact: Panic when rolling back migrations lacking .err.sql undo files (~98 migrations).
Root cause: getVersionSQL(..., false) panics on missing files (regression in 0bd3589a).
Fix: Restore ignoreErrors=true for rollback path.

Validation

  • go test ./util/... ./db/sql/... — pass
  • go test ./services/tasks/... ./db/... — pass
  • New unit tests for each fix

Recent commit scan

No new commits on develop since 2026-08-10 (d1238fad). Re-verified multi-select survey vars (PR #4118/#4124) and PocketID OIDC redirect (PR #4112) — no additional critical issues found.

Open in Web View Automation 

cursoragent and others added 3 commits August 15, 2026 11:04
When an OIDC provider returns no id_token and the UserInfo endpoint
fails, userInfo stays nil but Profile was read unconditionally,
panicking the server during sign-in.

Co-authored-by: Denis Gukov <fiftin@outlook.com>
SqlDbConnection.Close checked d.sql.Db but not d.sql itself. Migration
rollback used ignoreErrors=false, panicking when undo SQL files are missing.

Co-authored-by: Denis Gukov <fiftin@outlook.com>
IsUseRemoteRunner, GetRunnerRegistrationToken, and admin info dereferenced
conf.Runners without a nil check when runners config is omitted.

Co-authored-by: Denis Gukov <fiftin@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant