{"record":{"id":"29bd18452eb54d27","repo":"JuliusBrussee/caveman","slug":"githubapp-content-path-is-required","errorCode":null,"errorMessage":"githubapp: content path is required","messagePattern":"githubapp: content path is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/githubapp/githubapp.go","lineNumber":302,"sourceCode":"\tif status != http.StatusOK {\n\t\treturn out, fmt.Errorf(\"githubapp: get repo installation %s/%s: HTTP %d: %s\", owner, name, status, snippet(raw))\n\t}\n\tif err := json.Unmarshal(raw, &out); err != nil {\n\t\treturn out, fmt.Errorf(\"githubapp: decode repo installation: %w\", err)\n\t}\n\tif out.ID <= 0 {\n\t\treturn Installation{}, fmt.Errorf(\"githubapp: repo installation response carried no id\")\n\t}\n\treturn out, nil\n}\n\n// GetFileContent reads one repository file with an installation token. The\n// content endpoint returns base64; callers receive decoded bytes with a strict\n// 64 KiB post-decode ceiling because connection proofs are tiny text files.\nfunc (a *App) GetFileContent(ctx context.Context, token, owner, name, path, ref string) ([]byte, error) {\n\tsegments := strings.Split(strings.Trim(path, \"/\"), \"/\")\n\tif len(segments) == 0 || segments[0] == \"\" {\n\t\treturn nil, fmt.Errorf(\"githubapp: content path is required\")\n\t}\n\tfor i := range segments {\n\t\tsegments[i] = url.PathEscape(segments[i])\n\t}\n\tendpoint := \"/repos/\" + url.PathEscape(owner) + \"/\" + url.PathEscape(name) + \"/contents/\" + strings.Join(segments, \"/\")\n\tif strings.TrimSpace(ref) != \"\" {\n\t\tendpoint += \"?\" + url.Values{\"ref\": {ref}}.Encode()\n\t}\n\tstatus, raw, err := a.do(ctx, \"Bearer \"+token, http.MethodGet, endpoint, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif status != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"githubapp: get repository proof: HTTP %d: %s\", status, snippet(raw))\n\t}\n\tvar payload struct {\n\t\tType     string `json:\"type\"`\n\t\tEncoding string `json:\"encoding\"`","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/shared/platform/githubapp/githubapp.go#L284-L320","documentation":"Pre-flight validation error from GetFileContent: the required content path argument is empty or whitespace-only. The GitHub contents endpoint needs at least one non-empty path segment, so the call is refused before any installation token is spent.","triggerScenarios":"Calling GetFileContent(ctx, token, owner, name, \"\", ref) or with path=\"/\" or path=\"   \" — strings.Split(Trim(path,\"/\"),\"/\") yields an empty first segment.","commonSituations":"Path built dynamically from config or database and came out empty (missing config key); upstream caller stripped the path; a directory path of \"/\" passed instead of a file.","solutions":["Validate the path is non-empty at the call site before invoking GetFileContent","Trace where the path comes from (config/env/DB) — fix the source supplying the empty value","Pass the repo-relative file path, e.g. \"docs/proof.txt\", not a directory or absolute path"],"exampleFix":"// before\ncontent, err := app.GetFileContent(ctx, tok, owner, name, cfg.ProofPath, ref)\n// after\nif strings.TrimSpace(cfg.ProofPath) == \"\" {\n    return fmt.Errorf(\"proof path not configured\")\n}\ncontent, err := app.GetFileContent(ctx, tok, owner, name, strings.Trim(cfg.ProofPath, \"/\"), ref)","handlingStrategy":"validation","validationCode":"func validateProofPath(p string) error {\n    p = strings.TrimSpace(strings.Trim(p, \"/\"))\n    if p == \"\" { return errors.New(\"content path is required\") }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err := validateProofPath(path); err != nil {\n    return fmt.Errorf(\"invalid proof path: %w\", err)\n}\ncontent, err := app.GetFileContent(ctx, tok, owner, name, path, ref)","preventionTips":["Validate paths from config/env before API calls","Always pass repo-relative file paths, never directories or \"/\"","Fail fast at config load time when a required path is blank"],"tags":["github","validation","argument"],"backgroundTag":"empty-required-field","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}