googleapis/mcp-toolbox · warning

unable to validate reloaded edits: %w

Error message

unable to validate reloaded edits: %w

What it means

During dynamic config reload, `handleDynamicReload` calls `validateReloadEdits` and, if validation of the reloaded configuration fails, logs "unable to validate reloaded edits: %w" as a warning and returns the error. This means the edited config files picked up by the file watcher could not be initialized into server primitives (sources, auth services, embedding models, tools, prompts, groups). Crucially, the server keeps running with the previously loaded config — the bad reload is rejected, not fatal.

Source

Thrown at cmd/root.go:143

	// Register subcommands
	cmd.AddCommand(invoke.NewCommand(opts))
	cmd.AddCommand(skills.NewCommand(opts))
	cmd.AddCommand(serve.NewCommand(opts))
	cmd.AddCommand(migrate.NewCommand(opts))

	return cmd
}

func handleDynamicReload(ctx context.Context, cfg server.ServerConfig, s *server.Server) error {
	logger, err := util.LoggerFromContext(ctx)
	if err != nil {
		panic(err)
	}

	sourcesMap, authServicesMap, embeddingModelsMap, toolsMap, promptsMap, groupsMap, err := validateReloadEdits(ctx, cfg)
	if err != nil {
		errMsg := fmt.Errorf("unable to validate reloaded edits: %w", err)
		logger.WarnContext(ctx, errMsg.Error())
		return err
	}

	s.PrimitiveMgr.SetPrimitives(sourcesMap, authServicesMap, embeddingModelsMap, toolsMap, promptsMap, groupsMap)

	return nil
}

// validateReloadEdits checks that the reloaded config configs can initialized without failing
func validateReloadEdits(
	ctx context.Context, cfg server.ServerConfig,
) (map[string]sources.Source, map[string]auth.AuthService, map[string]embeddingmodels.EmbeddingModel, map[string]tools.Tool, map[string]prompts.Prompt, map[string]group.Group, error,
) {
	logger, err := util.LoggerFromContext(ctx)
	if err != nil {
		panic(err)
	}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Read the wrapped error after the warning in the server logs — it names the exact parse/init failure and file
  2. Fix the edited config file and save again; the watcher will retry the reload on the next change
  3. Compare against the last-known-good config (git diff) to spot what broke
  4. If the edit was intentional but invalid (e.g. missing env var), set the required environment variables then re-trigger a reload by touching the file
  5. The running server is unaffected — no restart is needed; the old config continues to serve
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-validate edited configs before the watcher reloads them
func configValid(path string) error {
	b, err := os.ReadFile(path)
	if err != nil { return err }
	var m map[string]any
	return yaml.Unmarshal(b, &m)
}

Try / catch

if err := validateReloadEdits(ctx, cfg); err != nil {
	logger.WarnContext(ctx, fmt.Sprintf("keeping previous config; reload rejected: %v", err))
	return err
}

Prevention

When it happens

Trigger: Editing a watched YAML config file while `toolbox serve --watch` (or equivalent folder watching) is active and the new content fails `InitializeConfigs` — e.g. a YAML syntax error, unknown tool/source kind, missing env var, or invalid group reference introduced by the edit.

Common situations: Saving a half-finished edit in an editor (partial YAML); renaming an env var referenced by a source; adding a tool with a typo'd `kind:`; CI/scripts rewriting configs in place while the server watches them.

Related errors


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/7c7cf33a3b12e67f. Report an issue: GitHub.