moeru-ai/airi · error · Error

Failed to remove provider

Error message

Failed to remove provider

What it means

Thrown by InferenceServiceProvidersService.deleteRemote when DELETE /v1/providers/:id returns non-ok. Like removeRemote for characters, this does not parse JSON on success; it only checks ok. Message discards the status.

Source

Thrown at packages/stage-ui/src/services/inference-service-providers.ts:175

        validated: provider.status === 'configured',
        validationBypassed: provider.status === 'bypassed',
      },
    }, requestOptions(options))
    if (!res.ok)
      throw new Error('Failed to add provider')

    const item = await res.json()
    options?.abortSignal?.throwIfAborted()
    return normalize(item)
  }

  async function deleteRemote(client: InferenceServiceProvidersRemoteClient, providerId: string, options?: InferenceServiceProviderServiceOptions): Promise<void> {
    options?.abortSignal?.throwIfAborted()
    const res = await client.api.v1.providers[':id'].$delete({
      param: { id: providerId },
    }, requestOptions(options))
    if (!res.ok)
      throw new Error('Failed to remove provider')
    options?.abortSignal?.throwIfAborted()
  }

  async function patchConfigRemote(
    client: InferenceServiceProvidersRemoteClient,
    providerId: string,
    config: Record<string, unknown>,
    status: ProviderValidationStatus,
    options?: InferenceServiceProviderServiceOptions,
  ): Promise<InferenceServiceProvider> {
    options?.abortSignal?.throwIfAborted()
    const res = await client.api.v1.providers[':id'].$patch({
      param: { id: providerId },
      json: {
        config,
        validated: status === 'configured',
        validationBypassed: status === 'bypassed',
      },

View on GitHub (pinned to 27111382b4)

Solutions

  1. Treat 404 as success if the provider is already gone locally (idempotent delete).
  2. Re-authenticate on 401/403 before retrying.
  3. Include res.status to allow 404-tolerant handling upstream.

Example fix

// before
if (!res.ok)
  throw new Error('Failed to remove provider')

// after
if (!res.ok && res.status !== 404)
  throw new Error(`Failed to remove provider ${providerId} (status ${res.status})`)
Defensive patterns

Strategy: try-catch

Validate before calling

// Idempotent delete; only auth and a valid id are needed.
function isValidProviderId(id: string): boolean {
  return typeof id === 'string' && id.length > 0
}

Try / catch

try {
  await deleteRemote(client, providerId)
}
catch (error) {
  // Patch service to expose status; tolerate 404 since the provider is already gone.
  // On 401/403 re-authenticate and retry once.
  throw error
}

Prevention

When it happens

Trigger: client.api.v1.providers[':id'].$delete({ param: { id } }) resolves with ok=false. Typical: 401/403 (not authenticated / not owner), 404 (provider already deleted), 500 (server).

Common situations: Double delete; deleting a provider removed by another client; expired session; permission mismatch.

Related errors


AI-assisted analysis of moeru-ai/airi@27111382b4 (2026-08-12). Data as JSON: /api/errors/dec8db727e7d6e2f. Report an issue: GitHub.