{"record":{"id":"2016f156ffc7ee23","repo":"github/github-mcp-server","slug":"failed-to-read-docs-file-w","errorCode":null,"errorMessage":"failed to read docs file: %w","messagePattern":"failed to read docs file: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cmd/github-mcp-server/feature_flag_docs.go","lineNumber":132,"sourceCode":"// (e.g. flag-gated dual registrations), the first occurrence wins, mirroring\n// AvailableTools' deterministic sort order.\nfunc indexToolsByName(tools []inventory.ServerTool) map[string]inventory.ServerTool {\n\tout := make(map[string]inventory.ServerTool, len(tools))\n\tfor _, tool := range tools {\n\t\tif _, ok := out[tool.Tool.Name]; ok {\n\t\t\tcontinue\n\t\t}\n\t\tout[tool.Tool.Name] = tool\n\t}\n\treturn out\n}\n\n// rewriteAutomatedSection reads a markdown file, replaces the content between\n// the named markers with body, and writes it back.\nfunc rewriteAutomatedSection(path, startMarker, endMarker, body string) error {\n\tcontent, err := os.ReadFile(path) //#nosec G304\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to read docs file: %w\", err)\n\t}\n\tupdated, err := replaceSection(string(content), startMarker, endMarker, body)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn os.WriteFile(path, []byte(updated), 0600) //#nosec G306\n}\n","sourceCodeStart":114,"sourceCodeEnd":140,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/cmd/github-mcp-server/feature_flag_docs.go#L114-L140","documentation":"Returned by rewriteAutomatedSection in the feature-flag docs generator when os.ReadFile(path) fails. This is a maintainer/CI codegen command (cmd/github-mcp-server feature-flag docs) that rewrites a marked section of a markdown file; the read fails when the file does not exist at the expected path or is not readable by the current user.","triggerScenarios":"Running the feature-flag docs generation command from a directory other than the repo root so the relative docs path does not resolve; the target markdown file was deleted or renamed; file permissions deny read access; a custom --path flag pointing at a nonexistent file.","commonSituations":"CI jobs that check out only a subset of the repo; running `go run ./cmd/github-mcp-server` from a subdirectory; docs restructured without updating the codegen paths.","solutions":["Run the command from the repository root so relative doc paths resolve","Verify the target file exists (ls docs/…) and matches the path passed to the generator","Fix file permissions if unreadable (chmod/chown)","If docs were restructured, update the hardcoded/default path in feature_flag_docs.go"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Verify the docs file exists before invoking the generator\nif _, err := os.Stat(docsPath); err != nil {\n    log.Fatalf(\"docs file missing: %s\", docsPath)\n}\n_ = rewriteDocs(docsPath)","typeGuard":null,"tryCatchPattern":"if err := rewriteAutomatedSection(path, start, end, body); err != nil {\n    if os.IsNotExist(err) || strings.Contains(err.Error(), \"failed to read docs file\") {\n        log.Fatalf(\"docs file not found at %s — run from repo root\", path)\n    }\n    return err\n}","preventionTips":["Run docs codegen from the repository root","Pre-check os.Stat on target files in the codegen entrypoint","Keep codegen paths in one place so doc restructures update them atomically"],"tags":["codegen","docs","file-io","ci"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}