Skip to content

Connectors: Verify AI provider API keys with php-ai-client - #13871

Closed
jorgefilipecosta wants to merge 4 commits into
WordPress:trunkfrom
jorgefilipecosta:fix/connectors-api-key-verify-provider-credentials
Closed

jorgefilipecosta wants to merge 4 commits into
WordPress:trunkfrom
jorgefilipecosta:fix/connectors-api-key-verify-provider-credentials

Conversation

@jorgefilipecosta

@jorgefilipecosta jorgefilipecosta commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

What

Alternative to #13870, to merge only after a php-ai-client release with WordPress/php-ai-client#299 is bundled. It shows how the fix looks when php-ai-client does the credentials check.

Testing

Verify unit tests are passing:

vendor/bin/phpunit --group connectors

Issue found via AI-assisted code review; fix and tests drafted with AI assistance (Claude Code) and reviewed by me.

Trac ticket: https://core.trac.wordpress.org/ticket/65551

Only discard a submitted key when the provider rejects it. A network
error, server error, or rate limit during validation no longer wipes the
key, a cached model list no longer validates a different key, and a
masked key submitted back to the settings endpoint keeps the stored key.

See #65551.
@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

The Connectors screen no longer submits a masked API key, as it shows a
stored key read-only until it is removed, so the setting does not need
to handle one: WordPress/gutenberg#83889

See #65551.
…rification.

Stand-in for bundling a php-ai-client release that includes
WordPress/php-ai-client#299. Generated with
tools/php-ai-client/installer.sh from 1.3.1 plus that change.
Use `ProviderRegistry::verifyProviderCredentials()` to validate a
submitted key instead of sending the list models request directly. It
tells a rejected key apart from one that cannot be verified, so the
workaround for `ListModelsApiBasedProviderAvailability::isConfigured()`
is no longer needed.

See #65551.
@jorgefilipecosta
jorgefilipecosta force-pushed the fix/connectors-api-key-verify-provider-credentials branch from a351d34 to 48e6fe8 Compare September 30, 2026 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant