Skip to content

cli.php: missing provider registration and .env loading causes "Provider not registered" error #223

@sarthak-19

Description

@sarthak-19

Description:

Bug Report

Summary

On running cli.php with any provider (e.g. --providerId=google) always fails with:

[ERROR] Invalid arguments while trying to set up prompt builder: Provider not registered: google

Cause

This happens even when the correct API key is set in .env and the provider packages (wordpress/google-ai-provider, wordpress/openai-ai-provider, wordpress/anthropic-ai-provider) are installed as dev dependencies.

cli.php is missing two bootstrapping steps that the integration test suite handles in tests/integration/bootstrap.php:

  1. Loading .env API keys in .env are never read into the environment, so getenv() calls inside providers return nothing.
  2. Registering providers — Provider classes (e.g. GoogleProvider) are never registered with the ProviderRegistry, so the registry has no providers to resolve by ID.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions