{"record":{"id":"c905fa8138db1131","repo":"chenhg5/cc-connect","slug":"empty-reference","errorCode":null,"errorMessage":"empty reference","messagePattern":"empty reference","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/reference_parse.go","lineNumber":55,"sourceCode":"\tisRelative     bool\n\tlocationFormat referenceLocationFormat\n\tlineStart      int\n\tlineEnd        int\n\tcolumn         int\n}\n\nvar (\n\treMarkdownLink   = regexp.MustCompile(`\\[([^\\]]+)\\]\\(([^)\\s]+)\\)((?::\\d+(?::\\d+)?|:\\d+-\\d+)?)?`)\n\treHashLocation   = regexp.MustCompile(`^(.*?)(#L(\\d+)(?:C(\\d+))?)$`)\n\treColonLineCol   = regexp.MustCompile(`^(.*):(\\d+):(\\d+)$`)\n\treColonLineRange = regexp.MustCompile(`^(.*):(\\d+)-(\\d+)$`)\n\treColonLineOnly  = regexp.MustCompile(`^(.*):(\\d+)$`)\n)\n\nfunc parseUserLocalReference(raw, workspaceDir string) (*localReference, error) {\n\traw = strings.TrimSpace(raw)\n\tif raw == \"\" {\n\t\treturn nil, fmt.Errorf(\"empty reference\")\n\t}\n\tif match := reMarkdownLink.FindStringSubmatch(raw); len(match) >= 3 && match[0] == raw {\n\t\tsuffix := \"\"\n\t\tif len(match) >= 4 {\n\t\t\tsuffix = match[3]\n\t\t}\n\t\traw = match[2] + suffix\n\t}\n\tref, ok := parseLocalReference(raw, workspaceDir)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"cannot parse local reference\")\n\t}\n\treturn ref, nil\n}\n\nfunc parseLocalReference(raw, workspaceDir string) (*localReference, bool) {\n\traw = strings.TrimSpace(raw)\n\tif raw == \"\" || isWebURL(raw) || strings.HasPrefix(raw, \"//\") {","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/reference_parse.go#L37-L73","documentation":"`parseUserLocalReference` first trims the raw input and rejects it outright with `empty reference` if nothing remains. This guards the reference-view feature from being invoked with no file path at all, before any pattern matching is attempted.","triggerScenarios":"Calling parseUserLocalReference (via buildReferenceViewRequest, e.g. from cmdShow or a message attachment handler) with `raw` empty or whitespace-only — e.g. a `/show` command with no argument, or an empty message attachment path.","commonSituations":"User sends `/show` with no arguments; the platform strips content so the reference string arrives as \"\" or \"   \"; upstream message parsing extracts an empty path from a malformed card/button payload.","solutions":["Check the user-facing command invocation includes a path argument (`/show src/main.go`, not bare `/show`).","Validate/trim the reference in the caller and return a usage hint to the user before calling buildReferenceViewRequest.","Fix the card/button template if it produces an empty path value.","Guard the call site: `if strings.TrimSpace(rawRef) == \"\" { reply usage; return }`."],"exampleFix":"// before\nreq, err := buildReferenceViewRequest(arg, workspaceDir)\n\n// after\narg = strings.TrimSpace(arg)\nif arg == \"\" {\n    reply(\"usage: /show <path[:line]>\")\n    return\n}\nreq, err := buildReferenceViewRequest(arg, workspaceDir)","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(rawRef) == \"\" {\n    reply(\"usage: /show <path[:line]>\")\n    return\n}","typeGuard":null,"tryCatchPattern":"req, err := buildReferenceViewRequest(arg, ws)\nif err != nil {\n    reply(\"could not read reference: \" + err.Error())\n    return\n}","preventionTips":["Trim and require a non-empty argument in command handlers before calling reference APIs.","Give users a usage message listing accepted reference forms.","Guard card/button templates so they never emit empty path values."],"tags":["validation","argument","go"],"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"}