Skip to content

Allow empty credentials when saving settings#1048

Merged
dkotter merged 6 commits intodevelopfrom
fix/allow-empty-credentials
Feb 10, 2026
Merged

Allow empty credentials when saving settings#1048
dkotter merged 6 commits intodevelopfrom
fix/allow-empty-credentials

Conversation

@dkotter
Copy link
Collaborator

@dkotter dkotter commented Feb 9, 2026

Description of the Change

We added the ability to easily filter Provider credentials in #1043. One comment on that PR flagged an issue with some Providers, where if you want to filter credentials you first need to add in dummy credentials in order for our pre-save checks to pass.

As a quick explanation, we had some checks in place where we wouldn't authenticate credentials if those credential fields were empty (no need to authenticate if we don't have an API key set, as an example). But in situations where you're overriding credentials, you shouldn't be forced to enter any credentials (dummy or not) in the admin first.

In investigating, found out that about half of our Providers worked fine but the others did not. In comparing those, the ones that work didn't check if credentials exist first before trying to authenticate and instead rely on the authentication check failing to alert the user that something is wrong. You could argue that's not the best user experience but it does more or less accomplish the same thing.

In order to keep this PR as simple as possible, I decided to follow that same approach on all the Providers that weren't working:

  • AWS Polly
  • Azure OpenAI
  • ElevenLabs
  • IBM Watson
  • Azure TTS
  • Azure AI Vision

All Providers should now have an authenticate_credentials method (most already did but not all) and we use that method as one of the first checks when sanitizing settings. If that check fails, we show an error message but we still save all settings (including any credential fields, even if blank).

How to test the Change

In particular, test the Providers listed above:

  1. Create a new plugin and hook into the new classifai_provider_credentials, overriding the credentials for the Providers you want to test
  2. Install that plugin and ClassifAI into a new environment
  3. Choose a Feature one of these Providers uses, configure any settings you may want (leaving credential fields blank) and then hit save. Ensure it authenticates correctly
  4. Optional: test that the Feature works as expected
  5. Disable the custom plugin and re-save a Feature, again leaving credential fields blank
  6. Ensure an error message shows

Changelog Entry

Added - Ensure all Providers have an authenticate_credentials method that we can use to validate the credentials are valid
Changed - Allow all settings to be saved, including credential fields, even if they are blank. This is mostly to support those using the new classifai_provider_credentials filter to override credentials

Credits

Props @peterwilsoncc, @dkotter

Checklist:

…credentials, allowing us to save empty values which allows us to override those credentials and still have auth work
…se credentials, allowing us to save empty values which allows us to override those credentials and still have auth work
… credentials, allowing us to save empty values which allows us to override those credentials and still have auth work
…ore attempting authentication, allowing credentials to be overridden
…those credentials, allowing us to save empty values which allows us to override those credentials and still have auth work
…ing credentials, allowing empty credentials to be saved and allowing those to be properly filtered
@dkotter dkotter added this to the 3.8.0 milestone Feb 9, 2026
@dkotter dkotter self-assigned this Feb 9, 2026
@dkotter dkotter requested review from a team and jeffpaul as code owners February 9, 2026 22:57
@github-actions github-actions bot added the needs:code-review This requires code review. label Feb 9, 2026
@github-actions
Copy link

github-actions bot commented Feb 9, 2026

✅ WordPress Plugin Check Report

✅ Status: Passed

📊 Report

All checks passed! No errors or warnings found.


🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

Copy link
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

For testing I used two approaches:

I've dropped a question inline as to whether we need a follow up ticket.

*
* @return bool|mixed The filtered value of connect to service.
*/
$pre = apply_filters( 'classifai_' . self::ID . '_pre_connect_to_service', false );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add this filter to the other providers?

Unrelated to this ticket/PR, not a merge consideration.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this was added specifically to help mock API responses for AWS Polly in our E2E tests. All other requests we mock using the pre_http_request filter but because we're using the AWS SDK here, these requests don't filter through the WordPress HTTP API and thus that filter never fires.

That said, I'm not opposed to more standard hooks here though I think worth thinking through once we look to standardize on using the PHP AI Client to make our requests (where possible)

@dkotter dkotter merged commit a58d566 into develop Feb 10, 2026
19 checks passed
@dkotter dkotter deleted the fix/allow-empty-credentials branch February 10, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:code-review This requires code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants