sipeed/picoclaw · error

config pre-check failed

Error message

config pre-check failed: %w

What it means

preCheckConfig rejected the loaded config during gateway Run (invalid gateway port range or another startup-blocking invariant). The failure is wrapped so startup halts before listeners and providers are created.

Solutions

  1. Check the wrapped message; fix gateway.port if it is outside 1-65535
  2. Validate the config in the web UI before restarting
  3. Correct the flagged setting in config.json and restart the gateway
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/gateway/gateway.go:157 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15). Data as JSON: /api/errors/ab8a94d82b20c915. Report an issue: GitHub.

Appendix: source

Thrown at pkg/gateway/gateway.go:157

	defer func() {
		if runErr != nil {
			logger.ErrorCF("gateway", "Gateway startup failed", map[string]any{
				"config_path": configPath,
				"error":       runErr.Error(),
				"home_path":   homePath,
				"allow_empty": allowEmptyStartup,
				"debug":       debug,
			})
		}
	}()

	cfg, err := config.LoadConfig(configPath)
	if err != nil {
		return fmt.Errorf("error loading config: %w", err)
	}

	if err = preCheckConfig(cfg); err != nil {
		return fmt.Errorf("config pre-check failed: %w", err)
	}

	// Debug mode permanently overrides the config log level to DEBUG.
	if debug {
		fmt.Println("🔍 Debug mode enabled")
	} else {
		effectiveLogLevel := config.EffectiveGatewayLogLevel(cfg)
		logger.SetLevelFromString(effectiveLogLevel)
		logger.Infof("Log level set to %q", effectiveLogLevel)
	}

	bindPlan, listenResult, err := openGatewayListeners(cfg.Gateway.Host, cfg.Gateway.Port)
	if err != nil {
		return fmt.Errorf("error opening gateway listeners: %w", err)
	}

	// Enforce singleton: write PID file with generated token.
	pidData, err := pid.WritePidFile(homePath, bindPlan.ProbeHost, cfg.Gateway.Port)

View on GitHub (pinned to 49183d7e8d)