{"record":{"id":"dadf906da8ec11b4","repo":"chenhg5/cc-connect","slug":"empty-path","errorCode":null,"errorMessage":"empty path","messagePattern":"empty path","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/reference_show.go","lineNumber":72,"sourceCode":"\tcase ref.locationFormat != referenceLocationNone:\n\t\treq.Mode = referenceViewContext\n\tdefault:\n\t\treq.Mode = referenceViewFileHead\n\t\treq.MaxLines = defaultShowHeadLines\n\t}\n\treturn req, nil\n}\n\nfunc renderReferenceView(req *referenceViewRequest) (string, error) {\n\tif req == nil || req.Ref == nil {\n\t\treturn \"\", fmt.Errorf(\"nil view request\")\n\t}\n\tpath := req.Ref.pathAbs\n\tif path == \"\" {\n\t\tpath = req.Ref.pathOriginal\n\t}\n\tif path == \"\" {\n\t\treturn \"\", fmt.Errorf(\"empty path\")\n\t}\n\tinfo, err := os.Stat(path)\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn \"\", fmt.Errorf(\"path does not exist\")\n\t\t}\n\t\treturn \"\", err\n\t}\n\tif info.IsDir() {\n\t\tif req.Ref.locationFormat != referenceLocationNone {\n\t\t\treturn \"\", fmt.Errorf(\"directory reference cannot carry a location\")\n\t\t}\n\t\treturn renderReferenceDir(path, req)\n\t}\n\treturn renderReferenceFile(path, req)\n}\n\nfunc renderReferenceFile(path string, req *referenceViewRequest) (string, error) {","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/reference_show.go#L54-L90","documentation":"After resolving the absolute path, renderReferenceView requires a non-empty filesystem path on the reference. If both pathAbs and pathOriginal are empty, there is no target to stat or render, so it fails fast with 'empty path'.","triggerScenarios":"A referenceViewRequest whose Ref has both pathAbs and pathOriginal set to \"\" — typically a reference created without any path field populated.","commonSituations":"Parsing logic that assigns the location but not the path; config where the reference string lacks the path component; tests constructing a Ref literal without path fields.","solutions":["Ensure the reference parser always sets pathAbs (or at least pathOriginal) before the request reaches renderReferenceView","Validate the reference input at parse time and reject empty paths earlier with a clearer message","In tests, set pathOriginal or pathAbs on the Ref"],"exampleFix":"// before\nref := &reference{locationFormat: referenceLocationLine}\n// after\nref := &reference{pathOriginal: \"main.go\", pathAbs: \"/repo/main.go\", locationFormat: referenceLocationLine}","handlingStrategy":"validation","validationCode":"if ref.pathAbs == \"\" && ref.pathOriginal == \"\" {\n    return \"\", fmt.Errorf(\"reference has no path\")\n}","typeGuard":"func hasPath(r *reference) bool { return r != nil && (r.pathAbs != \"\" || r.pathOriginal != \"\") }","tryCatchPattern":"out, err := renderReferenceView(req)\nif err != nil && strings.Contains(err.Error(), \"empty path\") {\n    return \"\", fmt.Errorf(\"show: reference missing a file path\")\n}","preventionTips":["Validate the reference string format at parse time (path is mandatory)","Set pathAbs immediately when constructing the reference from user input","Add a table-driven parser test covering references without paths"],"tags":["go","validation","empty-value"],"backgroundTag":"empty-required-field","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}