{"record":{"id":"46df6e06db0ab4a8","repo":"yudai/gotty","slug":"failed-to-read-custom-index-file-at-s","errorCode":null,"errorMessage":"failed to read custom index file at `%s`","messagePattern":"failed to read custom index file at `(.+?)`","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/server.go","lineNumber":47,"sourceCode":"\toptions *Options\n\n\tupgrader      *websocket.Upgrader\n\tindexTemplate *template.Template\n\ttitleTemplate *noesctmpl.Template\n}\n\n// New creates a new instance of Server.\n// Server will use the New() of the factory provided to handle each request.\nfunc New(factory Factory, options *Options) (*Server, error) {\n\tindexData, err := Asset(\"static/index.html\")\n\tif err != nil {\n\t\tpanic(\"index not found\") // must be in bindata\n\t}\n\tif options.IndexFile != \"\" {\n\t\tpath := homedir.Expand(options.IndexFile)\n\t\tindexData, err = ioutil.ReadFile(path)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"failed to read custom index file at `%s`\", path)\n\t\t}\n\t}\n\tindexTemplate, err := template.New(\"index\").Parse(string(indexData))\n\tif err != nil {\n\t\tpanic(\"index template parse failed\") // must be valid\n\t}\n\n\ttitleTemplate, err := noesctmpl.New(\"title\").Parse(options.TitleFormat)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to parse window title format `%s`\", options.TitleFormat)\n\t}\n\n\tvar originChekcer func(r *http.Request) bool\n\tif options.WSOrigin != \"\" {\n\t\tmatcher, err := regexp.Compile(options.WSOrigin)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"failed to compile regular expression of Websocket Origin: %s\", options.WSOrigin)\n\t\t}","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/yudai/gotty/blob/a080c85cbc59226c94c6941ad8c395232d72d517/server/server.go#L29-L65","documentation":"Wrapped ioutil.ReadFile error in Server.New when --index-file is set: the custom index page at the expanded path cannot be read (missing file, bad ~ expansion, or permission denied). Startup aborts because the fallback embedded index is intentionally not used.","triggerScenarios":"Thrown at server/server.go:47 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the path exists and is readable by the server user","Verify homedir expansion produced the intended absolute path","Point --index-file at an absolute path to avoid ~ expansion surprises"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a080c85cbc59226c94c6941ad8c395232d72d517","analyzedAt":"2026-09-02T16:42:38.150Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}