chenhg5/cc-connect · error
nil view request
Error message
nil view request
What it means
renderReferenceView validates that the caller passed a fully constructed *referenceViewRequest containing a non-nil Ref before rendering. A nil request or nil Ref means no reference was ever parsed/attached, so there is nothing to display. This is an internal invariant guard against programming mistakes upstream.
Source
Thrown at core/reference_show.go:65
MaxEntries: defaultShowMaxEntries,
}
switch {
case ref.kind == referenceKindDir:
req.Mode = referenceViewDir
case ref.locationFormat == referenceLocationColonRange:
req.Mode = referenceViewRange
case ref.locationFormat != referenceLocationNone:
req.Mode = referenceViewContext
default:
req.Mode = referenceViewFileHead
req.MaxLines = defaultShowHeadLines
}
return req, nil
}
func renderReferenceView(req *referenceViewRequest) (string, error) {
if req == nil || req.Ref == nil {
return "", fmt.Errorf("nil view request")
}
path := req.Ref.pathAbs
if path == "" {
path = req.Ref.pathOriginal
}
if path == "" {
return "", fmt.Errorf("empty path")
}
info, err := os.Stat(path)
if err != nil {
if os.IsNotExist(err) {
return "", fmt.Errorf("path does not exist")
}
return "", err
}
if info.IsDir() {
if req.Ref.locationFormat != referenceLocationNone {
return "", fmt.Errorf("directory reference cannot carry a location")View on GitHub (pinned to 4000b2338a)
Solutions
- Inspect how the referenceViewRequest is built before renderReferenceView is called and ensure buildReferenceViewRequest succeeded and returned a non-nil Ref
- In tests, populate req.Ref with a valid reference struct (e.g. via the reference parser) instead of passing a zero-value or nil request
- Wrap the call: only invoke renderReferenceView if req != nil && req.Ref != nil
Example fix
// before
out, err := renderReferenceView(req)
// after
if req == nil || req.Ref == nil {
return "", fmt.Errorf("show: no reference parsed")
}
out, err := renderReferenceView(req) Defensive patterns
Strategy: type-guard
Validate before calling
if req == nil || req.Ref == nil {
return "", fmt.Errorf("no reference parsed")
} Type guard
func hasRef(req *referenceViewRequest) bool { return req != nil && req.Ref != nil } Try / catch
out, err := renderReferenceView(req)
if err != nil {
if strings.Contains(err.Error(), "nil view request") {
// handle missing reference: reply with usage hint
return "", nil
}
return "", err
} Prevention
- Always build requests through the shared request-builder instead of struct literals
- Add a unit test asserting the parser never returns a request with nil Ref on success
- Run go vet / nilness linters to catch unchecked nil flows
When it happens
Trigger: Calling renderReferenceView (directly in tests, or via cmdShow) with a nil *referenceViewRequest, or with a request struct whose Ref field was never populated by the reference parser.
Common situations: Test code constructing referenceViewRequest by hand and forgetting to set Ref; a refactor of the request-building code that skips Ref population on an error path; calling cmdShow with a message that yielded no reference but the code path still proceeds to render.
Related errors
- listen for Agy permission hooks: %w
- generate permission bridge token: %w
- resolve home directory for Agy permission bridge: %w
- create Agy permission overlay: %w
- parse existing Agy hooks %s: %w
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/666ef5790a9a0b6d.
Report an issue: GitHub.