stacklok / stacklok/toolhive

EmbeddingServer finalizeEmbeddingServer silently ignores errors

Open
#4,624 1 comment 0 reactions 1 assignee View on GitHub

@Shashank-Panda is already working on this.

Since Jun 11, 2026.

bug go good-first-issue kubernetes operator
Dominant language
Go
Stars
2.2k
Forks
300
Avg merge
1d 15h
Merged PRs (30d)
184

Description

Summary

The finalizeEmbeddingServer method performs cleanup actions but returns void, silently discarding errors from status updates. If the status update fails, the finalizer is still removed by the caller and the object is deleted without the final status being persisted.

Severity: SHOULD FIX
Area: Controller Error Handling
Breaking: No

Location

  • cmd/thv-operator/controllers/embeddingserver_controller.go:1053-1067

Problem

func (r *EmbeddingServerReconciler) finalizeEmbeddingServer(
    ctx context.Context, es *v1alpha1.EmbeddingServer) {
    // Update status
    _ = r.Status().Update(ctx, es)  // error ignored
    r.Recorder.Eventf(es, ...)
}

If the status update fails (e.g., conflict, network error), the finalizer is still removed by the caller. The object is deleted without the final status being persisted.

Impact

  • Final status update may be lost silently
  • No retry mechanism for failed status updates during finalization
  • Observability gap: the last status of a deleted EmbeddingServer may not reflect the actual cleanup outcome
  • If cleanup involves more than just status updates in the future, errors from those operations would also be silently ignored

Recommended Fix

  1. Change finalizeEmbeddingServer to return an error:

    func (r *EmbeddingServerReconciler) finalizeEmbeddingServer(
        ctx context.Context, es *v1alpha1.EmbeddingServer) error {
        if err := r.Status().Update(ctx, es); err != nil {
            return fmt.Errorf("updating final status: %w", err)
        }
        r.Recorder.Eventf(es, ...)
        return nil
    }
    
  2. Handle the error in the caller — if finalization fails, requeue instead of removing the finalizer:

    if err := r.finalizeEmbeddingServer(ctx, es); err != nil {
        return ctrl.Result{}, err  // requeue; finalizer stays
    }
    // Only remove finalizer after successful finalization
    

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.