{"record":{"id":"3bb36f2897aa4e06","repo":"glanceapp/glance","slug":"validating-config-file-w","errorCode":null,"errorMessage":"validating config file: %w","messagePattern":"validating config file: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/glance/main.go","lineNumber":165,"sourceCode":"\n\tonErr := func(err error) {\n\t\tlog.Printf(\"Error watching config files: %v\", err)\n\t}\n\n\tconfigContents, configIncludes, err := parseYAMLIncludes(configPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"parsing config: %w\", err)\n\t}\n\n\tstopWatching, err := configFilesWatcher(configPath, configContents, configIncludes, onChange, onErr)\n\tif err == nil {\n\t\tdefer stopWatching()\n\t} else {\n\t\tlog.Printf(\"Error starting file watcher, config file changes will require a manual restart. (%v)\", err)\n\n\t\tconfig, err := newConfigFromYAML(configContents)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"validating config file: %w\", err)\n\t\t}\n\n\t\tapp, err := newApplication(config)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"creating application: %w\", err)\n\t\t}\n\n\t\tstartServer, _ := app.server()\n\t\tif err := startServer(); err != nil {\n\t\t\treturn fmt.Errorf(\"starting server: %w\", err)\n\t\t}\n\t}\n\n\t<-exitChannel\n\treturn nil\n}\n\nfunc serveUpdateNoticeIfConfigLocationNotMigrated(configPath string) bool {","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/glanceapp/glance/blob/91324e8de762702e97b0ac5c8e36271d644d8642/internal/glance/main.go#L147-L183","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nserver:\n  portt: 8080   # typo'd/unknown key\n# after\nserver:\n  port: 8080\n","handlingStrategy":"validation","validationCode":"// Strict-decode a probe struct mirroring top-level keys to catch unknowns\nvar probe map[string]yaml.Node\nif err := yaml.Unmarshal(cfg, &probe); err != nil { return err }\nfor k := range probe {\n    if !knownTopLevelKeys[k] { return fmt.Errorf(\"unknown top-level key %q\", k) }\n}\n","typeGuard":null,"tryCatchPattern":"Catch the %w chain; the strict decoder names the unknown/invalid key — fail the deploy with that message.","preventionTips":["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"],"tags":["config","validation","startup","file-watcher"],"backgroundTag":null,"analyzedSha":"91324e8de762702e97b0ac5c8e36271d644d8642","analyzedAt":"2026-08-15T14:12:54.279Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}