{"record":{"id":"d5c35e2057f86e64","repo":"cayleygraph/cayley","slug":"could-not-open-config-file-q-v","errorCode":null,"errorMessage":"could not open config file %q: %v","messagePattern":"could not open config file %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graph/gaedatastore/config.go","lineNumber":132,"sourceCode":"\tf, err := strconv.ParseFloat(text, 64)\n\t*d = duration(time.Duration(f) * time.Second)\n\treturn err\n}\n\nfunc (d *duration) MarshalJSON() ([]byte, error) {\n\treturn []byte(fmt.Sprintf(\"%q\", *d)), nil\n}\n\n// LoadConf reads a JSON-encoded config contained in the given file. A zero value\n// config is returned if the filename is empty.\nfunc LoadConf(file string) (*Config, error) {\n\tconfig := &Config{}\n\tif file == \"\" {\n\t\treturn config, nil\n\t}\n\tf, err := os.Open(file)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not open config file %q: %v\", file, err)\n\t}\n\tdefer f.Close()\n\n\tdec := json.NewDecoder(f)\n\terr = dec.Decode(config)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not parse config file %q: %v\", file, err)\n\t}\n\treturn config, nil\n}\n","sourceCodeStart":114,"sourceCodeEnd":143,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/graph/gaedatastore/config.go#L114-L143","documentation":"LoadConf loads a gaedatastore Config from a JSON file. If os.Open fails (file missing, no permissions, bad path), the open error is wrapped in this message with the file path. It is a config-file open failure raised before any JSON decoding happens.","triggerScenarios":"Calling configFrom/LoadConf with a file path that does not exist, is a directory, or is not readable by the process (os.Open returns an error).","commonSituations":"Typo in the -config path on GAE datastore startup; running the process from a different working directory so a relative path no longer resolves; file permissions changed after deployment.","solutions":["Verify the config file path exists and is spelled correctly (use an absolute path to avoid working-directory issues).","Check file permissions so the Cayley process user can read it (chmod/chown as needed).","Pass an empty file string if you intend to use the default zero-value Config instead of loading a file.","Confirm the path points to a file, not a directory."],"exampleFix":"// before\nconf, err := gaedatastore.LoadConf(\"gaecfg.json\") // relative path, file absent\n// after\nconf, err := gaedatastore.LoadConf(\"/app/config/gaedatastore.json\") // absolute, existing path","handlingStrategy":"validation","validationCode":"if _, err := os.Stat(path); err != nil {\n    return fmt.Errorf(\"gaedatastore config not readable: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"conf, err := gaedatastore.LoadConf(path)\nif err != nil {\n    var pe *fs.PathError\n    if errors.As(err, &pe) {\n        log.Fatalf(\"cannot open config %s: %v\", path, pe)\n    }\n    return err\n}","preventionTips":["Always use absolute paths for config files.","Stat the file before load in startup code.","Ensure the service user has read permissions on config files."],"tags":["config","file","gae"],"backgroundTag":"file-open-failed","analyzedSha":"81dcd7d73e45136bc0d01802a8ba4685d8a533eb","analyzedAt":"2026-09-06T06:14:12.358Z","contentChangedAt":"2026-09-06T06:14:12.358Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}