chenhg5/cc-connect · error

RunIsolationProbe: RunAsUser is empty

Error message

RunIsolationProbe: RunAsUser is empty

What it means

RunIsolationProbe runs the deeper run_as_user isolation checks (work_dir access, escalation probes) and produces a report. It returns this error immediately when cfg.RunAsUser is empty because no probe can be executed without a target user. The result report is still returned alongside the error for the caller to log.

Source

Thrown at core/runas_audit.go:168

	Runner     SudoRunner
	// ProbeScriptOverride, if non-nil, replaces the embedded probe
	// script. Tests use this; production always uses the embedded one.
	ProbeScriptOverride []byte
	Timeout             time.Duration
}

// RunIsolationProbe spawns the probe as the target user and parses its
// output. Does not fail on non-zero exit from the probe — whatever it
// managed to print is still parsed.
func RunIsolationProbe(ctx context.Context, cfg AuditConfig) (IsolationReport, error) {
	report := IsolationReport{
		Project:   cfg.Project,
		RunAsUser: cfg.RunAsUser,
		WorkDir:   cfg.WorkDir,
		Timestamp: time.Now().UTC(),
	}
	if cfg.RunAsUser == "" {
		return report, errors.New("RunIsolationProbe: RunAsUser is empty")
	}
	if cfg.Runner == nil {
		cfg.Runner = ExecSudoRunner{}
	}
	if cfg.Timeout == 0 {
		cfg.Timeout = 15 * time.Second
	}
	script := cfg.ProbeScriptOverride
	if script == nil {
		script = runasProbeScript
	}

	probeCtx, cancel := context.WithTimeout(ctx, cfg.Timeout)
	defer cancel()

	// Build env injection: since sudo -i strips env, we pass the probe
	// inputs as SHELL VARIABLES by prepending `export` statements to the
	// script body. Values are pre-validated at config parse time so

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Configure run_as_user for the project in config.toml before running the doctor probe.
  2. Skip the probe when RunAsUser is empty (the feature is disabled for that project).
  3. Populate ProbeConfig.RunAsUser from the parsed project config before invoking RunIsolationProbe.

Example fix

// before
report, err := core.RunIsolationProbe(ctx, cfg)
if err != nil {
    return err
}
// after
if cfg.RunAsUser == "" {
    return nil // run_as_user not configured; nothing to probe
}
report, err := core.RunIsolationProbe(ctx, cfg)
if err != nil {
    return fmt.Errorf("doctor: isolation probe: %w", err)
}
Defensive patterns

Strategy: validation

Validate before calling

if cfg.RunAsUser == "" {
    return nil, nil // probe not applicable
}

Try / catch

report, err := core.RunIsolationProbe(ctx, cfg)
if err != nil && cfg.RunAsUser != "" {
    slog.Error("isolation probe failed", "err", err)
}

Prevention

When it happens

Trigger: runDoctorOne or an anonymous doctor worker calls RunIsolationProbe with a ProbeConfig whose RunAsUser field is the empty string (core/runas_audit.go:168).

Common situations: Running `cc-connect doctor user-isolation` against a project with no run_as_user configured; config parse left RunAsUser empty after a schema change; building the ProbeConfig programmatically and forgetting to populate RunAsUser.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/485e2f121cf7b9e7. Report an issue: GitHub.