plandex-ai/plandex · error

error getting org user config: %v

Error message

error getting org user config: %v

What it means

This error is produced by a recovered panic inside the goroutine that loads the org user config via db.GetOrgUserConfig(auth.User.Id, auth.OrgId). The deferred recover() catches any panic (e.g. nil pointer dereference or nil map write inside the DB layer), converts it into an error, and sends it on errCh so the parent loadPendingBuilds flow fails fast instead of crashing. The message wraps the panic value, so the %v usually reads like 'runtime error: invalid memory address or nil pointer dereference'.

Source

Thrown at app/server/model/plan/build_load.go:113

				}
			}()
			res, err := db.GetPlanSettings(plan)
			if err != nil {
				log.Printf("Error getting plan settings: %v\n", err)
				errCh <- fmt.Errorf("error getting plan settings: %v", err)
				return
			}

			settings = res
			errCh <- nil
		}()

		go func() {

			defer func() {
				if r := recover(); r != nil {
					log.Printf("panic in getOrgUserConfig: %v\n%s", r, debug.Stack())
					errCh <- fmt.Errorf("error getting org user config: %v", r)
					runtime.Goexit() // don't allow outer function to continue and double-send to channel
				}
			}()

			res, err := db.GetOrgUserConfig(auth.User.Id, auth.OrgId)
			if err != nil {
				log.Printf("Error getting org user config: %v\n", err)
				errCh <- fmt.Errorf("error getting org user config: %v", err)
				return
			}

			orgUserConfig = res
			errCh <- nil
		}()

		for i := 0; i < 4; i++ {
			err = <-errCh
			if err != nil {

View on GitHub (pinned to e2d772072e)

Solutions

  1. Read the wrapped panic value and stack trace logged just before this error ("panic in getOrgUserConfig") to find the nil dereference source.
  2. Verify auth.User.Id and auth.OrgId are non-nil before starting the build so the DB call receives valid keys.
  3. Check that the database client used by db.GetOrgUserConfig is initialized and connected before builds run.
  4. Update/patch the DB layer or ORM driver if the panic originates inside the driver.
  5. Rerun the build; if transient (e.g. a race), add synchronization or a mutex around the shared config store.

Example fix

// before
res, err := db.GetOrgUserConfig(auth.User.Id, auth.OrgId)
// after
if auth == nil || auth.User == nil {
    errCh <- fmt.Errorf("cannot get org user config: missing auth user")
    return
}
res, err := db.GetOrgUserConfig(auth.User.Id, auth.OrgId)
Defensive patterns

Strategy: try-catch

Validate before calling

if auth == nil || auth.User == nil || auth.OrgId == "" {
    return fmt.Errorf("auth context incomplete: cannot load org user config")
}
if db == nil {
    return fmt.Errorf("db client not initialized")
}

Type guard

func authReady(a *types.AuthState) bool {
    return a != nil && a.User != nil && a.User.Id != "" && a.OrgId != ""
}

Try / catch

// panics in this library are converted to errors on errCh; read them like normal errors
for i := 0; i < 4; i++ {
    err = <-errCh
    if err != nil {
        if strings.HasPrefix(err.Error(), "error getting org user config: runtime error") {
            log.Printf("org user config loader panicked: %v", err)
        }
        return err
    }
}

Prevention

When it happens

Trigger: A panic occurs in the goroutine calling db.GetOrgUserConfig — e.g. a nil auth.User or nil db handle, a nil-pointer dereference inside the DB driver or config store, or concurrent map writes while fetching the org user config.

Common situations: Database client not initialized (nil *gorm.DB/sql.DB) at startup; auth context partially populated when a build is started from a stale session; a driver/ORM bug or incompatibility after a dependency upgrade; race conditions when multiple plans build concurrently.

Related errors


AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/f92f398c6a5ac7ac. Report an issue: GitHub.