Skip to content

[Bug]: get_all_provider_models() fails entirely when a single provider has stale credentials #2935

@tivris

Description

@tivris

Bug Description

When logging into a provider (e.g. forge provider login google_ai_studio), the login itself succeeds and prints "configured successfully", but then an unrelated error from a different configured provider is shown. For example, if Bedrock has stale credentials, you get:

$ forge provider login google_ai_studio
? Enter your GoogleAIStudio API key: AIza...
● [12:11:25] GoogleAIStudio configured successfully
● [12:11:25] ERROR: Bearer token is required in API key field

The "Bearer token is required" error comes from the Bedrock provider, not from Google AI Studio.

Root Cause

After a successful login, finalize_provider_activation() calls get_all_provider_models() to check model compatibility. That function fetches models from all configured providers concurrently, then collects results with:

futures::future::join_all(futures)
    .await
    .into_iter()
    .collect::<anyhow::Result<Vec<_>>>()

This .collect::<Result<Vec<_>>>() fails on the first error from any provider, discarding all successful results.

The function's own docstring already describes the intended behavior:

Returns a list of ProviderModels for each configured provider that successfully returned models. If every configured provider fails (e.g. due to an invalid API key), the first error encountered is returned so the caller receives the real underlying cause rather than an empty list.

But the implementation doesn't match. One stale provider blocks the entire model-fetching flow for all providers.

Steps to Reproduce

  1. Configure two providers (e.g. Bedrock and Google AI Studio)
  2. Let one provider's credentials become stale or invalid
  3. Run forge provider login <other_provider> with valid credentials
  4. Observe the error from the stale provider after the login succeeds

Expected Behavior

The login should succeed and model selection should work, showing models from the providers that responded successfully. Failed providers should be logged as warnings, not block the entire operation.

Actual Behavior

The login prints "configured successfully" but then immediately shows an error from the unrelated stale provider, blocking model selection.

Forge Version

2.9.8

Operating System & Version

Linux (WSL)

Installation Method

npm install -g forgecode

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions