Skip to content

[Capability] Make CompletionProvider's providerClass usable - #499

Open
chr-hertel wants to merge 1 commit into
mainfrom
fix-completion-provider-class
Open

[Capability] Make CompletionProvider's providerClass usable#499
chr-hertel wants to merge 1 commit into
mainfrom
fix-completion-provider-class

Conversation

@chr-hertel

Copy link
Copy Markdown
Member

Two bugs made #[CompletionProvider(providerClass: Foo::class)] impossible to use:

  • The constructor's exactly-one-source check was array_filter([$provider, $values, $enum])$providerClass was never counted, so the form always threw Only one of provider, values, or enum can be set. during newInstance(). Discovery catches that and drops the element, so the whole prompt/template silently disappeared.
  • Discoverer::getCompletionProviders() then stored $attributeInstance->provider in the providerClass branch — always null there. (ReflectedElementLoader already had this right.)

Both are covered by a new integration test that drives a real client against a real server over stdio. The fixture's provider takes a scalar the auto-wiring container cannot supply, so it can only come from Container::set() — completions arriving at all prove the attribute reached the registry and the container was asked to build it.

Verified the test actually catches both bugs: with neither fix the prompt is missing entirely (Prompt not found: "book_seat"), with only the constructor fixed the completions come back empty.

Note that provider: already accepts a class-string<ProviderInterface> and resolves it the same way, so providerClass is a redundant spelling — worth a follow-up on whether to deprecate one of them. This PR only stops the advertised parameter from throwing.

Found by Copilot's review on #492.

The constructor's exactly-one-source check never counted providerClass, so
the form always threw, and discovery stored the (always null) provider for it.
@chr-hertel chr-hertel added Server Issues & PRs related to the Server component bug Something isn't working labels Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Server Issues & PRs related to the Server component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant