Skip to content

Conversation

@norkunas
Copy link
Collaborator

@norkunas norkunas commented Feb 10, 2026

Pull Request

Related issue

Fixes #<issue_number>

What does this PR do?

  • Fixes collecting custom data providers

PR checklist

Please check if your PR fulfills the following requirements:

  • Did you use any AI tool while implementing this PR (code, tests, docs, etc.)? If yes, disclose it in the PR description and describe what it was used for. AI usage is allowed when it is disclosed.
  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

gemini 2.5 flash wrote the code

Summary by CodeRabbit

  • New Features
    • Custom data providers can be registered and configured; provider mappings are now collected and applied during startup rather than registered immediately.
  • Bug Fixes
    • Missing or invalid provider references now produce a clear validation error listing the affected entries.

@norkunas norkunas added the bug Something isn't working label Feb 10, 2026
@norkunas norkunas requested a review from Strift February 10, 2026 06:02
@coderabbitai
Copy link

coderabbitai bot commented Feb 10, 2026

📝 Walkthrough

Walkthrough

Collects custom data-provider declarations in the Meilisearch extension into a container parameter, then a compiler pass reads that parameter, validates service definitions (throws if missing), and attaches meilisearch.data_provider tags with the provided attributes.

Changes

Cohort / File(s) Summary
Compiler pass: apply deferred providers
src/DependencyInjection/Compiler/DataProviderPass.php
Reads .meilisearch.custom_data_providers container parameter, validates each declared service exists (throws InvalidArgumentException with indices on missing), and attaches meilisearch.data_provider tags with the provided attributes.
Extension: collect custom providers
src/DependencyInjection/MeilisearchExtension.php
Refactors registerDataProviders() to collect custom provider mappings into a local array and persist them to the container parameter .meilisearch.custom_data_providers instead of tagging provider services immediately.

Sequence Diagram(s)

sequenceDiagram
    participant Ext as MeilisearchExtension
    participant Container as ContainerParameters
    participant Pass as DataProviderPass
    participant Defs as ServiceDefinitions

    Ext->>Container: setParameter('.meilisearch.custom_data_providers', customProviders)
    Note over Container: Parameter stores mapping\n{ serviceId: [{index, class}, ...] }
    Container->>Pass: compiler pass executes
    Pass->>Container: readParameter('.meilisearch.custom_data_providers')
    Pass->>Defs: for each serviceId -> locate definition
    alt definition missing
        Defs-->>Pass: not found
        Pass-->>Ext: throw InvalidArgumentException (includes indices)
    else definition present
        Defs-->>Pass: definition found
        Pass->>Defs: add `meilisearch.data_provider` tags with attributes
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I gathered providers, one by one,
I tucked them safe till work begun—
A pass reads the list and knocks on each door,
Tags hop aboard and then skip for more! 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix collecting custom data providers' directly aligns with the main changes, which implement deferred collection of custom data providers across two compiler files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Feb 10, 2026

Codecov Report

❌ Patch coverage is 87.50000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.80%. Comparing base (b426fd6) to head (892978b).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
.../DependencyInjection/Compiler/DataProviderPass.php 77.77% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #435      +/-   ##
==========================================
+ Coverage   69.34%   69.80%   +0.45%     
==========================================
  Files          30       30              
  Lines        1491     1500       +9     
==========================================
+ Hits         1034     1047      +13     
+ Misses        457      453       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@src/DependencyInjection/Compiler/DataProviderPass.php`:
- Around line 23-35: Update the throw in the foreach in DataProviderPass to a
single-line throw and use the global function call: replace the multi-line throw
block with a single statement like throw new
\InvalidArgumentException(\sprintf('The service "%s" configured as a
"data_provider" for index "%s" was not found.', $serviceId,
$attributes['index'])); leaving the surrounding loop and the subsequent
->findDefinition(...)->addTag(...) call unchanged.

In `@src/DependencyInjection/MeilisearchExtension.php`:
- Around line 108-112: The current implementation builds $customProviders keyed
by the data_provider id so multiple indices referencing the same provider
overwrite each other; change MeilisearchExtension to append entries to
$customProviders (use [] to push an entry object/array containing 'service' =>
$indice['data_provider'], 'index' => $indexName, 'class' => $class) instead of
assigning by key, and update DataProviderPass (the compiler pass that reads this
parameter, e.g., DataProviderPass::process) to iterate the indexed list and
register/addTag or otherwise configure the provider for each entry so a single
provider service can be associated with multiple indices. Ensure the
DataProviderPass uses the 'service' field to group or tag the same service
multiple times rather than expecting unique keys.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/DependencyInjection/Compiler/DataProviderPass.php`:
- Around line 24-30: Replace the check using ContainerBuilder::hasDefinition
with a check that also respects aliases: in DataProviderPass where you currently
call $container->hasDefinition($serviceId) before calling
$container->findDefinition($serviceId), change the guard to use
$container->has($serviceId) so aliased service IDs are recognized; keep the
subsequent $container->findDefinition($serviceId) and the same exception message
using $serviceId and $tagsConfigs (or $indices) unchanged.
🧹 Nitpick comments (1)
src/DependencyInjection/Compiler/DataProviderPass.php (1)

20-36: Consider removing the temporary parameter after consumption.

Symfony convention for dot-prefixed (.meilisearch.custom_data_providers) internal parameters is to clean them up once consumed in the compiler pass so they don't leak into the compiled container.

Proposed fix
         if ($container->hasParameter('.meilisearch.custom_data_providers')) {
             $customProviders = $container->getParameter('.meilisearch.custom_data_providers');
+            $container->getParameterBag()->remove('.meilisearch.custom_data_providers');
 
             foreach ($customProviders as $serviceId => $tagsConfigs) {

@Strift Strift added this pull request to the merge queue Feb 10, 2026
Merged via the queue into meilisearch:main with commit 53d87cf Feb 10, 2026
32 checks passed
@norkunas norkunas deleted the fix branch February 10, 2026 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants