micro/go-micro · error

no values

Error message

no values

What it means

The in-memory config loader keeps loaded values in m.vals. Get normally delegates to m.vals.Get(path...), but if no values have ever been loaded (m.vals is nil) — typically because Load/Reload was never called or the loader was created with watch/options that skipped loading — it returns "no values". Watch calls Get first, so a disabled/unloaded loader also surfaces this error through Watch.

Source

Thrown at config/loader/memory/memory.go:322

	ch := m.snap.ChangeSet

	// we are truly screwed, trying to load in a hacked way
	v, err := m.opts.Reader.Values(ch)
	if err != nil {
		return nil, err
	}

	// lets set it just because
	m.vals = v

	if m.vals != nil {
		return m.vals.Get(path...)
	}

	// ok we're going hardcore now

	return nil, errors.New("no values")
}

func (m *memory) Load(sources ...source.Source) error {
	var gerrors []string

	for _, source := range sources {
		set, err := source.Read()
		if err != nil {
			gerrors = append(gerrors,
				fmt.Sprintf("error loading source %s: %v",
					source,
					err))
			// continue processing
			continue
		}
		m.Lock()
		m.sources = append(m.sources, source)
		m.sets = append(m.sets, set)

View on GitHub (pinned to 24529f1404)

Solutions

  1. Call Load (or config.Load with your sources) and check its error before calling Get or Watch.
  2. Inspect the joined error from Load — it aggregates per-source errors (including reload errors) — and fix the failing source.
  3. In tests, seed the loader with an in-memory source and Load it before asserting on values.
  4. If a value may legitimately be absent, use Get's error return to fall back to defaults instead of ignoring it.

Example fix

// before
v, _ := loader.Get("db", "host")
// after
if err := loader.Load(source); err != nil {
    log.Fatal(err)
}
v, err := loader.Get("db", "host")
if err != nil {
    v = defaultHost
}
Defensive patterns

Strategy: try-catch

Validate before calling

if loader == nil {
    return errors.New("loader not initialized")
}
if err := loader.Load(sources...); err != nil {
    return fmt.Errorf("loader has no values: %w", err)
}

Try / catch

v, err := loader.Get("db", "host")
if err != nil {
    if err.Error() == "no values" {
        v = defaultValue
    } else {
        return err
    }
}

Prevention

When it happens

Trigger: Calling loader.Get(path...) (directly or via loader.Watch) on a memory loader instance before any successful Load/Reload populated it, or after construction with sources that all failed, leaving m.vals nil.

Common situations: Building config from sources whose Load failed earlier (errors were joined but the app continued); creating a memory loader programmatically without calling Load; unit tests that construct the loader and immediately query values.

Related errors


AI-assisted analysis of micro/go-micro@24529f1404 (2026-09-01). Data as JSON: /api/errors/471f99e4356a644a. Report an issue: GitHub.