fix: lint cleanup across repo (errcheck, staticcheck, ineffassign, unused)
- daemon.go: real bug — maybeRetryParked resolved fg := d.forgeFor(task) (matching markDead's pattern) but called d.Forge.SetStateLabel instead of fg.SetStateLabel, silently using the wrong forge client for multi-identity/multi-forge task routing. Fixed to use fg throughout. - telegram.go: updateThreadID existed but was never called anywhere; wired it into updateLoggingMiddleware so debug logs include thread_id. - Two SA9003 empty-branch tests (nell adapter_test.go, tools toolentry_test.go) were dead assertions with no body; implemented the actual check instead of deleting them. - memory manager_test.go: mockProvider.lastConfigSchema/lastBackupPaths were declared but never recorded; wired GetConfigSchema/BackupPaths to populate them and strengthened the aggregation tests to assert on per-provider content, not just counts. - Removed genuinely dead gateway messageevent_test.go helpers (intPtr/ i64Ptr, marked //go:fix inline, already fully superseded by the new() builtin used throughout the file). - Remaining errcheck findings (defer Close/Flush/Write, os.Setenv, etc. in test files) fixed with the existing `_ = ` convention already used elsewhere in the codebase. go build ./..., go test ./... (all packages ok), and golangci-lint run ./... all clean.
This commit is contained in:
1 parent
64352a06f3
commit
6fe1a7d037
19 files changed
+219
-183
No files matched your search
@@ -475,7 +475,7 @@ func (d *Daemon) pollSQLite(ctx context.Context, fg forge.Forge, repo config.Rep
|
||||
d.acknowledge(ctx, fg, repo, is)
|
||||
return
|
||||
}
|
||||
d.maybeRetryParked(ctx, fg, repo, is)
|
||||
d.maybeRetryParked(ctx, repo, is)
|
||||
}
|
||||
|
||||
// pollNATS publishes discovered issues to NATS (new flow).
|
||||
@@ -487,7 +487,7 @@ func (d *Daemon) pollNATS(ctx context.Context, fg forge.Forge, repo config.Repo,
|
||||
return
|
||||
}
|
||||
if existing != nil {
|
||||
d.maybeRetryParked(ctx, fg, repo, is)
|
||||
d.maybeRetryParked(ctx, repo, is)
|
||||
return
|
||||
}
|
||||
if err := d.Nats.PublishTask(ctx, repo.Owner, repo.Name, is.Number, is.Title, is.Body, labels, identity); err != nil {
|
||||
@@ -620,10 +620,9 @@ func (d *Daemon) pollEither(ctx context.Context, repo config.Repo) []forge.Issue
|
||||
// maybeRetryParked requeues a parked task whose state label a human has
|
||||
// removed -- the forge-native retry trigger. When retry_count reaches the
|
||||
// configured max_retries the task moves to dead instead of requeuing.
|
||||
// fg is only used before task is loaded (the hasLabel short-circuit needs
|
||||
// no forge call); once task is available its own Identity is authoritative
|
||||
// for which forge client owns it, resolved via forgeFor.
|
||||
func (d *Daemon) maybeRetryParked(ctx context.Context, fg forge.Forge, repo config.Repo, is forge.Issue) {
|
||||
// The forge client is resolved from the task's own Identity via forgeFor
|
||||
// (not passed in) since that's authoritative for which forge client owns it.
|
||||
func (d *Daemon) maybeRetryParked(ctx context.Context, repo config.Repo, is forge.Issue) {
|
||||
if hasLabel(is.Labels, d.Cfg.Dispatch.StateLabel("parked")) {
|
||||
return
|
||||
}
|
||||
@@ -631,7 +630,7 @@ func (d *Daemon) maybeRetryParked(ctx context.Context, fg forge.Forge, repo conf
|
||||
if err != nil || task == nil || task.Status != store.StatusParked {
|
||||
return
|
||||
}
|
||||
fg = d.forgeFor(task)
|
||||
fg := d.forgeFor(task)
|
||||
|
||||
maxRetries := repo.EffectiveMaxRetries(d.Cfg.MaxRetries)
|
||||
|
||||
@@ -648,7 +647,7 @@ func (d *Daemon) maybeRetryParked(ctx context.Context, fg forge.Forge, repo conf
|
||||
d.Log.Error("increment retry_count failed", "issue", is.Number, "err", err)
|
||||
}
|
||||
d.Log.Info("parked task requeued via label removal", "repo", repo.FullName(), "issue", is.Number, "retry_count", task.RetryCount+1, "max_retries", maxRetries)
|
||||
d.Forge.SetStateLabel(ctx, repo.Owner, repo.Name, is.Number, d.Cfg.Dispatch.StateLabel("queued"), d.Cfg.Dispatch.LabelValues())
|
||||
fg.SetStateLabel(ctx, repo.Owner, repo.Name, is.Number, d.Cfg.Dispatch.StateLabel("queued"), d.Cfg.Dispatch.LabelValues())
|
||||
d.emit(events.Event{
|
||||
Kind: "task_retried", TaskID: task.ID,
|
||||
Repo: repo.FullName(), Issue: is.Number, Detail: "parked label removed",
|
||||
|
||||
@@ -543,7 +543,7 @@ func TestMaybeRetryParkedUnderThreshold(t *testing.T) {
|
||||
is := forge.Issue{Number: 1, Labels: []string{}}
|
||||
repo := config.Repo{Owner: "acme", Name: "todo"}
|
||||
|
||||
d.maybeRetryParked(ctx, d.Forge, repo, is)
|
||||
d.maybeRetryParked(ctx, repo, is)
|
||||
|
||||
task, err := s.TaskByIssue(ctx, "acme", "todo", 1)
|
||||
if err != nil || task == nil {
|
||||
@@ -572,7 +572,7 @@ func TestMaybeRetryParkedAtThreshold(t *testing.T) {
|
||||
is := forge.Issue{Number: 1, Labels: []string{}}
|
||||
repo := config.Repo{Owner: "acme", Name: "todo"}
|
||||
|
||||
d.maybeRetryParked(ctx, d.Forge, repo, is)
|
||||
d.maybeRetryParked(ctx, repo, is)
|
||||
|
||||
task, err := s.TaskByIssue(ctx, "acme", "todo", 1)
|
||||
if err != nil || task == nil {
|
||||
@@ -601,7 +601,7 @@ func TestMaybeRetryParkedSkipsDead(t *testing.T) {
|
||||
is := forge.Issue{Number: 1, Labels: []string{}}
|
||||
repo := config.Repo{Owner: "acme", Name: "todo"}
|
||||
|
||||
d.maybeRetryParked(ctx, d.Forge, repo, is)
|
||||
d.maybeRetryParked(ctx, repo, is)
|
||||
|
||||
if len(fg.stateLabels) != 0 {
|
||||
t.Fatalf("expected no state label calls, got %d", len(fg.stateLabels))
|
||||
@@ -689,7 +689,7 @@ func TestMaybeRetryParkedStillParked(t *testing.T) {
|
||||
is := forge.Issue{Number: 1, Labels: []string{"archie:parked", "bug"}}
|
||||
repo := config.Repo{Owner: "acme", Name: "todo"}
|
||||
|
||||
d.maybeRetryParked(ctx, d.Forge, repo, is)
|
||||
d.maybeRetryParked(ctx, repo, is)
|
||||
|
||||
if len(fg.stateLabels) != 0 {
|
||||
t.Fatalf("expected no state label calls, got %d", len(fg.stateLabels))
|
||||
@@ -705,7 +705,7 @@ func TestMaybeRetryParkedRepoOverride(t *testing.T) {
|
||||
is := forge.Issue{Number: 1, Labels: []string{}}
|
||||
repo := config.Repo{Owner: "acme", Name: "todo", MaxRetries: 1}
|
||||
|
||||
d.maybeRetryParked(ctx, d.Forge, repo, is)
|
||||
d.maybeRetryParked(ctx, repo, is)
|
||||
|
||||
task, err := s.TaskByIssue(ctx, "acme", "todo", 1)
|
||||
if err != nil || task == nil {
|
||||
|
||||
Reference in new issue
Block a user