glanceapp/glance · error
validating config file: %w
Error message
validating config file: %w
What it means
Startup error raised in the fallback path when the config file watcher could not be started: main.go re-validates by calling newConfigFromYAML(configContents) and that validation failed. Despite the 'validating' label, it covers strict YAML decoding into the typed config struct — unknown fields, bad types, failed custom unmarshalers (e.g. orderedYAMLMap errors) all surface here.
Source
Thrown at internal/glance/main.go:165
onErr := func(err error) {
log.Printf("Error watching config files: %v", err)
}
configContents, configIncludes, err := parseYAMLIncludes(configPath)
if err != nil {
return fmt.Errorf("parsing config: %w", err)
}
stopWatching, err := configFilesWatcher(configPath, configContents, configIncludes, onChange, onErr)
if err == nil {
defer stopWatching()
} else {
log.Printf("Error starting file watcher, config file changes will require a manual restart. (%v)", err)
config, err := newConfigFromYAML(configContents)
if err != nil {
return fmt.Errorf("validating config file: %w", err)
}
app, err := newApplication(config)
if err != nil {
return fmt.Errorf("creating application: %w", err)
}
startServer, _ := app.server()
if err := startServer(); err != nil {
return fmt.Errorf("starting server: %w", err)
}
}
<-exitChannel
return nil
}
func serveUpdateNoticeIfConfigLocationNotMigrated(configPath string) bool {View on GitHub (pinned to 91324e8de7)
Solutions
- Read the wrapped error for the offending key/line and fix or remove it
- Cross-check the config against the current glance config reference for renamed fields after upgrades
- Fix the watcher environment (raise fs.inotify.max_user_watches, ensure /proc and inotify available) so the normal hot-reload path is used
Example fix
# before server: portt: 8080 # typo'd/unknown key # after server: port: 8080
Defensive patterns
Strategy: validation
Validate before calling
// Strict-decode a probe struct mirroring top-level keys to catch unknowns
var probe map[string]yaml.Node
if err := yaml.Unmarshal(cfg, &probe); err != nil { return err }
for k := range probe {
if !knownTopLevelKeys[k] { return fmt.Errorf("unknown top-level key %q", k) }
}
Try / catch
Catch the %w chain; the strict decoder names the unknown/invalid key — fail the deploy with that message.
Prevention
- Remove/rename old keys after glance upgrades (check release notes)
- Keep inotify limits healthy so the validated fallback path is rarely taken
- Version-pin glance and keep the config reference for that version
When it happens
Trigger: The filesystem watcher init failed (e.g. inotify limits, unsupported FS) AND the config, while syntactically parseable, violates the typed schema: unknown top-level keys, wrong field types, invalid widget/struct fields caught by KnownFields-strict decoding.
Common situations: Upgrading glance and keeping old config keys that were renamed/removed; watcher unavailable in restricted containers forcing this path; typos in top-level config sections.
Related errors
- secret-key must be exactly %d bytes
- initializing preset theme %s: %v
- initializing default theme: %v
- URL is required
- nested groups are not supported
AI-assisted analysis of glanceapp/glance@91324e8de7 (2026-08-15).
Data as JSON: /api/errors/3bb36f2897aa4e06.
Report an issue: GitHub.