Skip to content

Connectors: Allow hyphens in connector IDs#11285

Closed
gziolo wants to merge 6 commits intoWordPress:trunkfrom
gziolo:fix/64861-connector-id-allow-hyphens
Closed

Connectors: Allow hyphens in connector IDs#11285
gziolo wants to merge 6 commits intoWordPress:trunkfrom
gziolo:fix/64861-connector-id-allow-hyphens

Conversation

@gziolo
Copy link
Copy Markdown
Member

@gziolo gziolo commented Mar 18, 2026

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

Summary

  • Expands connector ID validation from /^[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).
  • Hyphens in connector IDs are normalized to underscores when auto-generating setting_name (e.g. azure-openaiconnectors_ai_azure_openai_api_key), consistent with how the WP AI Client library already builds env var names.
  • Updates existing tests to use hyphen-based IDs and adds three new tests covering the hyphen acceptance, underscore acceptance, and hyphen-to-underscore normalization in setting names.

Test plan

  • Run npm run test:php -- --filter=Tests_Connectors_WpConnectorRegistry — all 31 tests pass.
  • Register a third-party AI provider with a hyphenated ID (e.g. azure-openai) and confirm it appears on Settings → Connectors without a _doing_it_wrong notice.
  • Confirm the generated option name is connectors_ai_azure_openai_api_key (underscores).

🤖 Generated with Claude Code

…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>
@gziolo gziolo self-assigned this Mar 18, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 18, 2026

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props gziolo, jorgefilipecosta, westonruter, flixos90, mukesh27.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@gziolo
Copy link
Copy Markdown
Member Author

gziolo commented Mar 18, 2026

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, - gets replaced with _. Therefore, it might be worth exploring a stricter standardization in the PHP API client to avoid mismatches, too.

Alternatively, we allow both _ and - for connector names.

@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.

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>
Copy link
Copy Markdown
Member

@jorgefilipecosta jorgefilipecosta left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
gziolo and others added 2 commits March 18, 2026 15:27
Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
Copy link
Copy Markdown
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

@gziolo LGTM, just one doc update needed.

Co-authored-by: Felix Arntz <flixos90@gmail.com>
pento pushed a commit that referenced this pull request Mar 19, 2026
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
@github-actions
Copy link
Copy Markdown

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 62056
GitHub commit: b8e0c3d

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions bot closed this Mar 19, 2026
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Mar 19, 2026
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
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.

5 participants