Connectors: Allow hyphens in connector IDs#11285
Connectors: Allow hyphens in connector IDs#11285gziolo wants to merge 6 commits intoWordPress:trunkfrom
Conversation
…ing names. Changes the connector ID validation regex from `/^[a-z0-9_]+$/` to `/^[a-z0-9-]+$/`, aligning with the naming conventions used by the Abilities API, and WordPress.org plugin slugs (all kebab-case, no underscores). Hyphens in connector IDs are normalized to underscores when generating the `setting_name` (e.g. `azure-openai` produces `connectors_ai_azure_openai_api_key`), matching the convention already used by the WP AI Client library when building env var names. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
It's still an open question whether we should include similar validation for AI providers, because it currently allows almost anything, with the note that when handling environment variables and PHP constant names, Alternatively, we allow both |
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Updates the mock AI Client provider from `mock_connectors_test` to `mock-connectors-test` to align with the new connector ID convention (hyphens allowed, underscores not). Also updates the setting_name assertion to account for hyphen-to-underscore normalization. See #64861 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
felixarntz
left a comment
There was a problem hiding this comment.
@gziolo LGTM, just one doc update needed.
Co-authored-by: Felix Arntz <flixos90@gmail.com>
Expands the connector ID validation regex from `/^[a-z0-9_]+$/` to `/^[a-z0-9_-]+$/`, aligning with the PHP AI Client library naming conventions. Hyphens are normalized to underscores when generating `setting_name` (e.g., `azure-openai` → `connectors_ai_azure_openai_api_key`). Developed in #11285. Props pers, gziolo, jorgefilipecosta, westonruter, flixos90, mukesh27. Fixes #64861. git-svn-id: https://develop.svn.wordpress.org/trunk@62056 602fd350-edb4-49c9-b593-d223f7449a82
Expands the connector ID validation regex from `/^[a-z0-9_]+$/` to `/^[a-z0-9_-]+$/`, aligning with the PHP AI Client library naming conventions. Hyphens are normalized to underscores when generating `setting_name` (e.g., `azure-openai` → `connectors_ai_azure_openai_api_key`). Developed in WordPress/wordpress-develop#11285. Props pers, gziolo, jorgefilipecosta, westonruter, flixos90, mukesh27. Fixes #64861. Built from https://develop.svn.wordpress.org/trunk@62056 git-svn-id: http://core.svn.wordpress.org/trunk@61338 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Trac ticket: https://core.trac.wordpress.org/ticket/64861
Summary
/^[a-z0-9_]+$/to/^[a-z0-9_-]+$/, adding hyphen support alongside the existing underscore support. This aligns with WordPress.org plugin slug conventions (kebab-case).setting_name(e.g.azure-openai→connectors_ai_azure_openai_api_key), consistent with how the WP AI Client library already builds env var names.Test plan
npm run test:php -- --filter=Tests_Connectors_WpConnectorRegistry— all 31 tests pass.azure-openai) and confirm it appears on Settings → Connectors without a_doing_it_wrongnotice.connectors_ai_azure_openai_api_key(underscores).🤖 Generated with Claude Code