docs: phase 3a — nilerr review, all 11 sites were false positives (qa4)
97 -> 85. Not one of the eleven nilerr findings was a bug.
I called these "real bug candidates" when I planned the phases. I was
wrong, and the reason is worth recording: every site is the same
deliberate idiom, and a linter cannot see intent.
- inprocess.go (5) and gateway.go (2) are handlers that report a
problem as TEXT to their consumer. A tool handler returning a Go
error aborts the tool call; returning "rejected: ..." lets the model
read the feedback and retry with valid arguments. A chat handler
returning a Go error surfaces as a gateway fault instead of a usage
hint to the human.
- worker.go carries runErr in the response envelope's Error field.
Returning it as a Go error too would double-report and abort the
NATS reply.
- email.go returns nil when Accept fails because context cancellation
closed the listener. That is a clean shutdown.
- codesearch.go skips an unreadable entry and continues the walk. A
best-effort index must not abort on one bad file.
- skill.go is documented in the function comment already: a
non-directory skills path means "no skills", not a fatal error.
Annotated each with //nolint:nilerr and the specific reason rather than
excluding the linter by path, so nilerr stays live everywhere else and
the next reader wondering "why nil here?" gets an answer at the site.
This is the phase I insisted on keeping single-session and out of the
subagent fan-out. A worker told to "fix nilerr" would have converted all
eleven to error returns: malformed tool arguments would hard-fail the
agent loop instead of being correctable, chat typos would read as
gateway faults, and shutdown would log spurious errors. Every test would
still have passed.
This commit is contained in:
1 parent
4ee8579ddc
commit
529b25eada
8 files changed
+19
-11
No files matched your search
@@ -171,7 +171,7 @@ func captureToolSet(specs []CaptureTool, captures map[string][]json.RawMessage)
|
||||
}
|
||||
var object map[string]json.RawMessage
|
||||
if err := json.Unmarshal(value, &object); err != nil {
|
||||
return spec.Name + " rejected: arguments must be a JSON object", nil
|
||||
return spec.Name + " rejected: arguments must be a JSON object", nil //nolint:nilerr // the agent loop must see malformed tool arguments as feedback it can correct, not as a failed tool call
|
||||
}
|
||||
for _, field := range spec.RequiredFields {
|
||||
if _, ok := object[field]; !ok {
|
||||
@@ -181,13 +181,13 @@ func captureToolSet(specs []CaptureTool, captures map[string][]json.RawMessage)
|
||||
for _, field := range spec.NonEmptyStrings {
|
||||
var text string
|
||||
if raw, ok := object[field]; !ok || json.Unmarshal(raw, &text) != nil || strings.TrimSpace(text) == "" {
|
||||
return fmt.Sprintf("%s rejected: %s must be a non-empty string", spec.Name, field), nil
|
||||
return fmt.Sprintf("%s rejected: %s must be a non-empty string", spec.Name, field), nil //nolint:nilerr // same: a rejection message lets the model retry with a valid argument
|
||||
}
|
||||
}
|
||||
for _, field := range spec.BooleanFields {
|
||||
var value bool
|
||||
if raw, ok := object[field]; !ok || json.Unmarshal(raw, &value) != nil {
|
||||
return fmt.Sprintf("%s rejected: %s must be a boolean", spec.Name, field), nil
|
||||
return fmt.Sprintf("%s rejected: %s must be a boolean", spec.Name, field), nil //nolint:nilerr // same: a rejection message lets the model retry with a valid argument
|
||||
}
|
||||
}
|
||||
captures[spec.Name] = append(captures[spec.Name], append(json.RawMessage(nil), value...))
|
||||
@@ -215,11 +215,11 @@ func scriptToolSet(workspace string) core.ToolSet {
|
||||
Path string `json:"path"`
|
||||
}
|
||||
if err := json.Unmarshal([]byte(input), &args); err != nil || strings.TrimSpace(args.Path) == "" {
|
||||
return "run_go_script rejected: arguments must be a JSON object with a non-empty path field", nil
|
||||
return "run_go_script rejected: arguments must be a JSON object with a non-empty path field", nil //nolint:nilerr // same: a rejection message lets the model retry with a valid path
|
||||
}
|
||||
full := filepath.Join(workspace, args.Path)
|
||||
if rel, err := filepath.Rel(workspace, full); err != nil || strings.HasPrefix(rel, "..") {
|
||||
return "run_go_script rejected: path escapes the workspace", nil
|
||||
return "run_go_script rejected: path escapes the workspace", nil //nolint:nilerr // same: a rejection message lets the model retry with a valid path
|
||||
}
|
||||
out, err := skillscript.Run(full)
|
||||
if err != nil {
|
||||
|
||||
@@ -108,7 +108,7 @@ func runStages(ctx context.Context, runner Runner, msg AgentRequestMessage, chan
|
||||
Error: runErr.Error(),
|
||||
Channel: channel,
|
||||
}
|
||||
return resp, nil
|
||||
return resp, nil //nolint:nilerr // runErr is reported to the caller in the response envelope's Error field; returning it here as well would double-report and abort the NATS reply
|
||||
}
|
||||
totalTokens += result.TokensUsed
|
||||
totalIter += result.Iterations
|
||||
|
||||
@@ -82,7 +82,7 @@ func (g *Gateway) Start(ctx context.Context, router *gateway.Router) error {
|
||||
conn, err := ln.Accept()
|
||||
if err != nil {
|
||||
if ctx.Err() != nil {
|
||||
return nil
|
||||
return nil //nolint:nilerr // Accept failed because the listener was closed by context cancellation, which is a clean shutdown, not a failure
|
||||
}
|
||||
g.log.Error("email accept", "err", err)
|
||||
continue
|
||||
|
||||
@@ -340,7 +340,7 @@ func (r *Router) handleApprove(ctx context.Context, rest string) (string, error)
|
||||
identity, arg := parseTaskControl(rest, r.Identity)
|
||||
id, err := parseTaskID(arg)
|
||||
if err != nil {
|
||||
return "Usage: /approve [identity=name] <task-id>", nil
|
||||
return "Usage: /approve [identity=name] <task-id>", nil //nolint:nilerr // chat commands report problems as text to the human, never as Go errors, which would surface as a gateway fault
|
||||
}
|
||||
if err := r.Controller.Approve(ctx, id, identity); err != nil {
|
||||
return fmt.Sprintf("Cannot approve task %d: %v", id, err), nil
|
||||
@@ -355,7 +355,7 @@ func (r *Router) handleCancel(ctx context.Context, rest string) (string, error)
|
||||
identity, arg := parseTaskControl(rest, r.Identity)
|
||||
id, err := parseTaskID(arg)
|
||||
if err != nil {
|
||||
return "Usage: /cancel [identity=name] <task-id>", nil
|
||||
return "Usage: /cancel [identity=name] <task-id>", nil //nolint:nilerr // chat commands report problems as text to the human, never as Go errors, which would surface as a gateway fault
|
||||
}
|
||||
if err := r.Controller.Cancel(ctx, id, identity); err != nil {
|
||||
return fmt.Sprintf("Cannot cancel task %d: %v", id, err), nil
|
||||
|
||||
@@ -523,7 +523,7 @@ func WorkspaceFiles(ctx context.Context, root string) ([]string, error) {
|
||||
var files []string
|
||||
err = filepath.WalkDir(root, func(path string, entry os.DirEntry, walkErr error) error {
|
||||
if walkErr != nil {
|
||||
return nil
|
||||
return nil //nolint:nilerr // an unreadable entry skips that path and continues the walk; a best-effort index must not abort on one bad file
|
||||
}
|
||||
if path != root && strings.HasPrefix(entry.Name(), ".") {
|
||||
if entry.IsDir() {
|
||||
|
||||
@@ -189,24 +189,31 @@ type mockConsumer struct {
|
||||
func (m *mockConsumer) Fetch(int, ...jetstream.FetchOpt) (jetstream.MessageBatch, error) {
|
||||
return m.batch, nil
|
||||
}
|
||||
|
||||
func (m *mockConsumer) FetchBytes(int, ...jetstream.FetchOpt) (jetstream.MessageBatch, error) {
|
||||
panic("FetchBytes not implemented")
|
||||
}
|
||||
|
||||
func (m *mockConsumer) FetchNoWait(int) (jetstream.MessageBatch, error) {
|
||||
panic("FetchNoWait not implemented")
|
||||
}
|
||||
|
||||
func (m *mockConsumer) Consume(jetstream.MessageHandler, ...jetstream.PullConsumeOpt) (jetstream.ConsumeContext, error) {
|
||||
panic("Consume not implemented")
|
||||
}
|
||||
|
||||
func (m *mockConsumer) Messages(...jetstream.PullMessagesOpt) (jetstream.MessagesContext, error) {
|
||||
panic("Messages not implemented")
|
||||
}
|
||||
|
||||
func (m *mockConsumer) Next(...jetstream.FetchOpt) (jetstream.Msg, error) {
|
||||
panic("Next not implemented")
|
||||
}
|
||||
|
||||
func (m *mockConsumer) Info(context.Context) (*jetstream.ConsumerInfo, error) {
|
||||
panic("Info not implemented")
|
||||
}
|
||||
|
||||
func (m *mockConsumer) CachedInfo() *jetstream.ConsumerInfo {
|
||||
panic("CachedInfo not implemented")
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ func Catalog(dir string) ([]CatalogEntry, error) {
|
||||
if err != nil {
|
||||
// A file at .agents/skills (ENOTDIR) is not fatal -- treat as no skills.
|
||||
// Same for permission errors and other non-fatal ReadDir failures.
|
||||
return nil, nil
|
||||
return nil, nil //nolint:nilerr // documented above: a non-directory or unreadable skills path means no skills, not a fatal error
|
||||
}
|
||||
|
||||
var names []string
|
||||
|
||||
@@ -275,6 +275,7 @@ func archieBranch(issue int, title, body, labels string) string {
|
||||
// branchPrefix derives a conventional-commit prefix from the issue
|
||||
// labels, then falls back to "feat". Maps: bug→fix, feature→feat,
|
||||
// enhancement→feat, docs→docs, chore→chore, test→test.
|
||||
// FIXME - Unused parameters title and body where they should be used. - just a missing implementation by the looks of it.
|
||||
func branchPrefix(title, body, labels string) string {
|
||||
for l := range strings.SplitSeq(labels, ",") {
|
||||
switch strings.TrimSpace(strings.ToLower(l)) {
|
||||
|
||||
Reference in new issue
Block a user