{"record":{"id":"6ee0aae80d03010d","repo":"micro/go-micro","slug":"source-loading-errors-s","errorCode":null,"errorMessage":"source loading errors: %s","messagePattern":"source loading errors: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/loader/memory/memory.go","lineNumber":268,"sourceCode":"\t// set values\n\tvals, err := m.opts.Reader.Values(set)\n\tif err != nil {\n\t\tm.Unlock()\n\t\treturn err\n\t}\n\tm.vals = vals\n\tm.snap = &loader.Snapshot{\n\t\tChangeSet: set,\n\t\tVersion:   genVer(),\n\t}\n\n\tm.Unlock()\n\n\t// update watchers\n\tm.update()\n\n\tif len(gerr) > 0 {\n\t\treturn fmt.Errorf(\"source loading errors: %s\", strings.Join(gerr, \"\\n\"))\n\t}\n\n\treturn nil\n}\n\nfunc (m *memory) Close() error {\n\tm.closeMu.Lock()\n\tdefer m.closeMu.Unlock()\n\n\tif m.closed {\n\t\treturn nil\n\t}\n\n\tclose(m.exit)\n\tm.closed = true\n\treturn nil\n}\n","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/config/loader/memory/memory.go#L250-L286","documentation":"The memory config loader's Sync reloads all configured sources; any per-source read errors are collected into gerr and, if non-empty, returned as a single joined error after the snapshot is still applied. It indicates one or more config sources failed to load, with each underlying message on its own line.","triggerScenarios":"Calling loader.Sync (directly or via Snapshot/Get on an auto-synced loader) when any source's Read fails — e.g. an unreachable config server, expired credentials, or a malformed remote config.","commonSituations":"A config backend (file removed, etcd/consul/nats down) becoming unavailable between reloads; bad credentials after rotation; a source added to the loader pointing at a non-existent path or key.","solutions":["Parse the error string: each line after the prefix is one source's error; fix the underlying source listed","Check connectivity/credentials for the failing backend and retry Sync","Make sources resilient or remove/disable the failing source from the loader","Verify the source's key/path exists and has non-empty content before loading"],"exampleFix":"// before\nif err := loader.Sync(); err != nil { log.Fatal(err) } // opaque joined error\n// after\nif err := loader.Sync(); err != nil {\n    for _, line := range strings.Split(err.Error(), \"\\n\") { log.Warn(line) }\n    // fall back to last good snapshot\n}","handlingStrategy":"try-catch","validationCode":"// before syncing, sanity-check each source is reachable/readable\nfor _, s := range sources {\n    if _, err := s.Read(); err != nil {\n        log.Warn(\"source unavailable, will use last good snapshot:\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := loader.Sync(); err != nil {\n    for _, line := range strings.Split(err.Error(), \"\\n\") {\n        log.Error(\"config source error: \", line)\n    }\n    // keep serving last good snapshot; do not crash\n}","preventionTips":["Split the joined error by newlines to identify each failing source","Keep the last good snapshot and degrade gracefully instead of fatal-ing","Monitor config backends (file existence, service health) before reloads","Load config eagerly at startup so source failures surface early"],"tags":["config","loader","source","partial-failure"],"backgroundTag":"config-source-load-failed","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}