Tencent/WeKnora · error

remote sandbox Get returned ID

Error message

remote sandbox Get returned ID %q for binding %q

What it means

This error indicates an invariant violation: the provider's Get returned a sandbox summary whose ID differs from the sandbox ID stored in the session binding. Since Get was called with binding.SandboxID, a mismatched ID means the provider is returning inconsistent or corrupted data, so the library aborts rather than connecting to an unexpected sandbox.

Solutions

  1. Check the RemoteClient implementation for ID normalization (trim/case changes) and make Get echo the requested ID verbatim
  2. Delete the stale binding and re-resolve so a fresh binding is created with the provider's actual ID
  3. Verify you are talking to the same provider project/account that created the sandbox
  4. If using a proxy or custom transport, ensure it does not rewrite sandbox identifiers

Example fix

// before (custom client returns normalized ID)
return &RemoteSandboxSummary{ID: strings.ToLower(id)}, nil
// after
return &RemoteSandboxSummary{ID: id}, nil // echo the requested ID exactly
Defensive patterns

Strategy: type-guard

Type guard

func saneSummary(summary *sandbox.RemoteSandboxSummary, want string) bool {
    return summary != nil && summary.ID == want
}

Try / catch

handle, err := session.Resolve(ctx, key)
if err != nil && strings.Contains(err.Error(), "returned ID") {
    // provider returned a mismatched ID: purge binding and re-resolve
    _ = bindings.Delete(ctx, key)
    handle, err = session.Resolve(ctx, key)
}

Prevention

When it happens

Trigger: client.Get(ctx, binding.SandboxID) succeeds but the returned summary.ID != binding.SandboxID — essentially only possible with a misbehaving or buggy provider client implementation, ID normalization differences (case/whitespace), or a provider proxy rewriting IDs.

Common situations: Custom or mock RemoteClient implementations returning canned summaries with different IDs; provider SDK normalizing IDs (e.g. trimming or lowercasing); routing through a proxy/gateway that remaps sandbox IDs; stale bindings reused across provider account/project switches.

Related errors


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/290e033f88d4872d. Report an issue: GitHub.

Appendix: source

Thrown at internal/sandbox/session_lifecycle.go:247

	return l.createAndBind(ctx, key)
}

func (l *remoteSessionLifecycle) connectBinding(
	ctx context.Context,
	binding SessionSandboxBinding,
) (RemoteSandboxHandle, bool, error) {
	summary, err := l.client.Get(ctx, binding.SandboxID)
	if err != nil {
		if CanReplaceRemoteBinding(err) {
			return nil, true, nil
		}
		return nil, false, fmt.Errorf("get bound remote sandbox: %w", err)
	}
	if summary == nil {
		return nil, false, errors.New("remote sandbox Get returned nil summary")
	}
	if summary.ID != binding.SandboxID {
		return nil, false, fmt.Errorf(
			"remote sandbox Get returned ID %q for binding %q",
			summary.ID,
			binding.SandboxID,
		)
	}
	if summary.State == RemoteStateTerminal {
		return nil, true, nil
	}

	handle, err := l.client.Connect(ctx, binding.SandboxID)
	if err != nil {
		if CanReplaceRemoteBinding(err) {
			return nil, true, nil
		}
		return nil, false, fmt.Errorf("connect bound remote sandbox: %w", err)
	}
	if err := l.validateHandle(handle, binding.SandboxID); err != nil {
		return nil, false, err

View on GitHub (pinned to 988cbb0330)