{"record":{"id":"771711b3db430818","repo":"glanceapp/glance","slug":"getting-absolute-path-of-s-w","errorCode":null,"errorMessage":"getting absolute path of %s: %w","messagePattern":"getting absolute path of (.+?): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/glance/config.go","lineNumber":258,"sourceCode":"var configIncludePattern = regexp.MustCompile(`(?m)^([ \\t]*)(?:-[ \\t]*)?(?:!|\\$)include:[ \\t]*(.+)$`)\n\nfunc parseYAMLIncludes(mainFilePath string) ([]byte, map[string]struct{}, error) {\n\treturn recursiveParseYAMLIncludes(mainFilePath, nil, 0)\n}\n\nfunc recursiveParseYAMLIncludes(mainFilePath string, includes map[string]struct{}, depth int) ([]byte, map[string]struct{}, error) {\n\tif depth > CONFIG_INCLUDE_RECURSION_DEPTH_LIMIT {\n\t\treturn nil, nil, fmt.Errorf(\"recursion depth limit of %d reached\", CONFIG_INCLUDE_RECURSION_DEPTH_LIMIT)\n\t}\n\n\tmainFileContents, err := os.ReadFile(mainFilePath)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"reading %s: %w\", mainFilePath, err)\n\t}\n\n\tmainFileAbsPath, err := filepath.Abs(mainFilePath)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"getting absolute path of %s: %w\", mainFilePath, err)\n\t}\n\tmainFileDir := filepath.Dir(mainFileAbsPath)\n\n\tif includes == nil {\n\t\tincludes = make(map[string]struct{})\n\t}\n\tvar includesLastErr error\n\n\tmainFileContents = configIncludePattern.ReplaceAllFunc(mainFileContents, func(match []byte) []byte {\n\t\tif includesLastErr != nil {\n\t\t\treturn nil\n\t\t}\n\n\t\tmatches := configIncludePattern.FindSubmatch(match)\n\t\tif len(matches) != 3 {\n\t\t\tincludesLastErr = fmt.Errorf(\"invalid include match: %v\", matches)\n\t\t\treturn nil\n\t\t}","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/glanceapp/glance/blob/91324e8de762702e97b0ac5c8e36271d644d8642/internal/glance/config.go#L240-L276","documentation":"filepath.Abs failed for the config/include path while resolving includes. Abs only fails when os.Getwd fails (usually because the working directory was deleted) since it converts any path to absolute without touching the filesystem. The path and wrapped error are included in the message.","triggerScenarios":"The glance process's current working directory is removed while it loads config with a relative path, causing Getwd inside filepath.Abs to fail.","commonSituations":"Running glance from a directory that a deployment script or container orchestration deleted/replaced mid-run; exotic environments where the cwd is inaccessible. Rarely seen in normal operation.","solutions":["Restart the process from a directory that exists","Pass an absolute config path so the cwd is irrelevant","Fix the deployment step that removes the working directory before/while the process starts"],"exampleFix":"# before\n./glance --config glance.yml   # run from a dir that may vanish\n# after\n./glance --config /etc/glance/glance.yml","handlingStrategy":"try-catch","validationCode":"if wd, err := os.Getwd(); err != nil {\n    log.Fatal(\"working directory unavailable: \", err)\n}","typeGuard":null,"tryCatchPattern":"if err := loadConfig(p); err != nil {\n    if strings.Contains(err.Error(), \"getting absolute path\") {\n        // cwd vanished; retry from a known directory with absolute path\n    }\n}","preventionTips":["Run long-lived services with an absolute config path","Avoid launching processes from temp/build directories"],"tags":["glance","filesystem","cwd","rare"],"backgroundTag":null,"analyzedSha":"91324e8de762702e97b0ac5c8e36271d644d8642","analyzedAt":"2026-08-15T14:12:54.279Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}