chenhg5/cc-connect · error
empty reference
Error message
empty reference
What it means
`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.
Source
Thrown at core/reference_parse.go:55
isRelative bool
locationFormat referenceLocationFormat
lineStart int
lineEnd int
column int
}
var (
reMarkdownLink = regexp.MustCompile(`\[([^\]]+)\]\(([^)\s]+)\)((?::\d+(?::\d+)?|:\d+-\d+)?)?`)
reHashLocation = regexp.MustCompile(`^(.*?)(#L(\d+)(?:C(\d+))?)$`)
reColonLineCol = regexp.MustCompile(`^(.*):(\d+):(\d+)$`)
reColonLineRange = regexp.MustCompile(`^(.*):(\d+)-(\d+)$`)
reColonLineOnly = regexp.MustCompile(`^(.*):(\d+)$`)
)
func parseUserLocalReference(raw, workspaceDir string) (*localReference, error) {
raw = strings.TrimSpace(raw)
if raw == "" {
return nil, fmt.Errorf("empty reference")
}
if match := reMarkdownLink.FindStringSubmatch(raw); len(match) >= 3 && match[0] == raw {
suffix := ""
if len(match) >= 4 {
suffix = match[3]
}
raw = match[2] + suffix
}
ref, ok := parseLocalReference(raw, workspaceDir)
if !ok {
return nil, fmt.Errorf("cannot parse local reference")
}
return ref, nil
}
func parseLocalReference(raw, workspaceDir string) (*localReference, bool) {
raw = strings.TrimSpace(raw)
if raw == "" || isWebURL(raw) || strings.HasPrefix(raw, "//") {View on GitHub (pinned to 4000b2338a)
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 }`.
Example fix
// before
req, err := buildReferenceViewRequest(arg, workspaceDir)
// after
arg = strings.TrimSpace(arg)
if arg == "" {
reply("usage: /show <path[:line]>")
return
}
req, err := buildReferenceViewRequest(arg, workspaceDir) Defensive patterns
Strategy: validation
Validate before calling
if strings.TrimSpace(rawRef) == "" {
reply("usage: /show <path[:line]>")
return
} Try / catch
req, err := buildReferenceViewRequest(arg, ws)
if err != nil {
reply("could not read reference: " + err.Error())
return
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- antigravity: invalid permission behavior %q
- auth.json missing tokens.access_token
- auth.json missing tokens.account_id
- tmux: 'session' option is required (name of the tmux session
- %s must be true or false
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/c905fa8138db1131.
Report an issue: GitHub.