Skip to content

EnsureProvider should be idempotent — fails with AlreadyExists on repeated runs #28

Description

@guyoron1

Mirrored from fullsend-ai#2294 for Phase 2 QF integration testing

Problem

When running fullsend run twice against the same gateway (e.g. during local testing), the second run fails at the "Ensuring provider" step with:

provider create "github" failed: Error: × status: AlreadyExists, message: "provider already exists"

EnsureProvider in internal/sandbox/sandbox.go calls openshell provider create and treats any error as a hard failure. There is no handling for the AlreadyExists case — no silent success, no delete-and-recreate fallback, and no update path. The function comment says "creates or updates a provider" but only the create path is implemented.

The current workaround is to manually delete providers between runs (openshell provider delete github jira), which makes iterative local testing painful. Any failed or interrupted run leaves stale providers that block the next run.

Expected Behavior

EnsureProvider should be idempotent, consistent with the codebase's conventions:

  • The Provider interface requires Provision() implementations to be idempotent
  • EnsureGateway() is documented as idempotent in ADR 0030
  • The "Ensure" naming convention implies idempotent semantics

Possible Approaches

  1. Succeed silently on AlreadyExists — if the provider is already configured, treat it as success (true "Ensure" semantics)
  2. Delete and recreate — on AlreadyExists, delete the existing provider and create a fresh one with current credentials
  3. Hybrid — try create; on AlreadyExists, update or delete+recreate

The right choice depends on whether credentials could change between runs. Option 1 is simpler but may leave stale credentials; option 2 is safer for credential rotation.

Related

There is a related idempotency gap in InferenceLayer.Install() (inference.go:56-69) where the idempotency guard checks whether secrets exist but not whether the values are correct, allowing stale or incorrect values to persist across re-runs.


Reported by @mrizzi

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpr-openAn open PR already addresses this issuepriority/highSignificant impact, address soonready-to-codeTriaged and ready for the code agent

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions