Skip to content

Register IEmbeddingProvider service for PostgreSqlContentIndexing dependency #1642

Closed

Description

@meshweaver-cloud

What is failing

The MCP tool search_chunks fails at startup on both Memex portal pods because Autofac cannot resolve MeshWeaver.Hosting.Embeddings.IEmbeddingProvider when activating IChunkedContentVectorStore.

Probable cause — high confidence

The AddPostgreSqlContentIndexing extension method registers IChunkedContentVectorStore with a factory lambda that takes IEmbeddingProvider as a dependency. The Memex deployment calls AddPostgreSqlContentIndexing but does not register IEmbeddingProvider in the Autofac container — visible in the stack trace at PostgreSqlContentIndexingExtensions.<>c.<AddPostgreSqlContentIndexing>b__1_0(IServiceProvider sp). The fix is to either:

  1. Register a concrete IEmbeddingProvider before calling AddPostgreSqlContentIndexing, or
  2. Make AddPostgreSqlContentIndexing self-contained by registering a default embedding provider when none is present (e.g., using TryAdd or ResolveOptional).

Impact

The search_chunks MCP tool is non-functional across both deployment pods. This was hit at deployment startup (2 occurrences, one per pod, within the same second) — every invocation of the tool on either pod will produce the same failure until the registration is fixed.

Where to look

  • PostgreSqlContentIndexingExtensions.cs — the registration lambda at AddPostgreSqlContentIndexing that injects IEmbeddingProvider.
  • The Memex portal's Startup / DI configuration (where AddPostgreSqlContentIndexing is called) — verify IEmbeddingProvider is registered beforehand.
  • MeshWeaver.Hosting.Embeddings.IEmbeddingProvider — the missing service interface.

Evidence

Fingerprint 6d40a3352d852518
Category ModelContextProtocol.Server.McpServer
Severity Error
Exception System.InvalidOperationException
Top frame Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetRequiredService(Type serviceType)
Namespace memex
Pods memex-portal-deployment-f666d6c4d-4pnzt, memex-portal-deployment-79cddfb6b7-l7gvv
Occurrences 2
First seen 2026-08-15 20:21:17Z
Last seen 2026-08-15 20:21:17Z
Recent log lines
2026-08-15 20:21:17Z memex-portal-deployment-f666d6c4d-4pnzt fail: ModelContextProtocol.Server.McpServer[1433779783]
      "search_chunks" threw an unhandled exception.
      System.InvalidOperationException: An exception was thrown while activating MeshWeaver.ContentCollections.Indexing.IChunkedContentVectorStore.
       ---> Autofac.Core.DependencyResolutionException: An exception was thrown while activating MeshWeaver.ContentCollections.Indexing.IChunkedContentVectorStore.
       ---> System.InvalidOperationException: The requested service 'MeshWeaver.Hosting.Embeddings.IEmbeddingProvider' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.
      
      See https://autofac.rtfd.io/help/service-not-registered for more info.
       ---> Autofac.Core.Registration.ComponentNotRegisteredException: The requested service 'MeshWeaver.Hosting.Embeddings.IEmbeddingProvider' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.
      
      See https://autofac.rtfd.io/help/service-not-registered for more info.
         at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetRequiredService(Type serviceType)
         --- End of inner exception stack trace ---
         at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetRequiredService(Type serviceType)
         at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
         at MeshWeaver.ContentCollections.Indexing.PostgreSql.PostgreSqlContentIndexingExtensions.<>c__1`1.<AddPostgreSqlContentIndexing>b__1_0(IServiceProvider sp) in /home/runner/work/MeshWeaver/MeshWeaver/src/MeshWeaver.ContentCollections.Indexing.PostgreSql/PostgreSqlContentIndexingE…[truncated]
2026-08-15 20:21:17Z memex-portal-deployment-79cddfb6b7-l7gvv fail: ModelContextProtocol.Server.McpServer[1433779783]
      "search_chunks" threw an unhandled exception.
      System.InvalidOperationException: An exception was thrown while activating MeshWeaver.ContentCollections.Indexing.IChunkedContentVectorStore.
       ---> Autofac.Core.DependencyResolutionException: An exception was thrown while activating MeshWeaver.ContentCollections.Indexing.IChunkedContentVectorStore.
       ---> System.InvalidOperationException: The requested service 'MeshWeaver.Hosting.Embeddings.IEmbeddingProvider' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.
      
      See https://autofac.rtfd.io/help/service-not-registered for more info.
       ---> Autofac.Core.Registration.ComponentNotRegisteredException: The requested service 'MeshWeaver.Hosting.Embeddings.IEmbeddingProvider' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.
      
      See https://autofac.rtfd.io/help/service-not-registered for more info.
         at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetRequiredService(Type serviceType)
         --- End of inner exception stack trace ---
         at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetRequiredService(Type serviceType)
         at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
         at MeshWeaver.ContentCollections.Indexing.PostgreSql.PostgreSqlContentIndexingExtensions.<>c__1`1.<AddPostgreSqlContentIndexing>b__1_0(IServiceProvider sp) in /home/runner/work/MeshWeaver/MeshWeaver/src/MeshWeaver.ContentCollections.Indexing.PostgreSql/PostgreSqlContentIndexingE…[truncated]

Opened automatically from Admin/_LogIncident/6d40a3352d852518. Recurrences are folded into this issue rather than opening new ones.

Activity

  1. rbuergi commented on Aug 25, 2026

    @rbuergi
    Contributor

    Fixed by #2248 (a3118e886).

    Correcting the record first: a claim circulated during triage tonight that IEmbeddingProvider was "registered nowhere" — that was wrong, and it came from a grep for AddSingleton<IEmbeddingProvider> that missed the registration living inside the AddEmbeddings extension (src/MeshWeaver.Hosting.Embeddings/EmbeddingExtensions.cs, present since 91ea0c2c1, and called from both Memex.Portal.Distributed/Program.cs:188 and the migration host). The provider is registered where embeddings are configured.

    What was actually wrong, and is now fixed:

    1. The capability had no explicit signal. Consumers each re-derived "do we have embeddings?" from options, so a second copy of CreateEmbeddingProvider's branch logic could drift and advertise a capability the host does not have. There is now an explicit EmbeddingCapability (src/MeshWeaver.Hosting.Embeddings/EmbeddingCapability.cs) — the registration itself is the signal, read once rather than re-derived.

    2. A second, independent defect found while doing it — and this is the sharper one. PostgreSqlExtensions.cs:161, :206 and SnowflakeExtensions.cs:138 each called services.BuildServiceProvider() mid-registration to read the optional provider. That builds a second, throwaway container: anything registered after that line is invisible to it, and any singleton it resolves is a duplicate of the one every other consumer gets. So whether those adapters had embeddings depended on whether the host called AddEmbeddings before or after — with both failure modes invisible, presenting identically as a silent degrade to lexical search.

      Fixed by building the adapters from the real container via a new AddPersistence(Func<IServiceProvider, IStorageAdapter>) overload. No services.BuildServiceProvider() remains on any registration path in src/ or memex/.

      Those three lanes currently have no callers (the portals use AddPartitionedPostgreSqlPersistence), so it was latent — but it would have quietly defeated the capability fix the moment one was used.

  2. systemorph-com commented on Sep 17, 2026

    @systemorph-com
    Contributor

    Reopened — this fault is happening again.

    Still occurring: 11 more since the last update (13 total).

    • Last seen: 2026-08-18 11:42:40Z
    • Pods: memex-portal-deployment-f666d6c4d-4pnzt, memex-portal-deployment-79cddfb6b7-l7gvv, memex-portal-deployment-68795ccb45-4dpdk, memex-portal-deployment-68795ccb45-hzj6p, memex-portal-deployment-f47f8cdd-f8fmq, memex-portal-deployment-76b967b5fb-pkw5p, memex-portal-deployment-745df44fc8-gtrfd, memex-portal-deployment-745df44fc8-drjtp
    Recent log lines
    2026-08-18 07:22:41Z memex-portal-deployment-745df44fc8-gtrfd fail: ModelContextProtocol.Server.McpServer[1433779783]
          "search_chunks" threw an unhandled exception.
          System.InvalidOperationException: An exception was thrown while activating MeshWeaver.ContentCollections.Indexing.IChunkedContentVectorStore.
           ---> Autofac.Core.DependencyResolutionException: An exception was thrown while activating MeshWeaver.ContentCollections.Indexing.IChunkedContentVectorStore.
           ---> System.InvalidOperationException: The requested service 'MeshWeaver.Hosting.Embeddings.IEmbeddingProvider' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.
          
          See https://autofac.rtfd.io/help/service-not-registered for more info.
           ---> Autofac.Core.Registration.ComponentNotRegisteredException: The requested service 'MeshWeaver.Hosting.Embeddings.IEmbeddingProvider' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.
          
          See https://autofac.rtfd.io/help/service-not-registered for more info.
             at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetRequiredService(Type serviceType)
             --- End of inner exception stack trace ---
             at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetRequiredService(Type serviceType)
             at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
             at MeshWeaver.ContentCollections.Indexing.PostgreSql.PostgreSqlContentIndexingExtensions.<>c__1`1.<AddPostgreSqlContentIndexing>b__1_0(IServiceProvider sp) in /home/runner/work/MeshWeaver/MeshWeaver/src/MeshWeaver.ContentCollections.Indexing.PostgreSql/PostgreSqlContentIndexingE…[truncated]
    2026-08-18 07:22:44Z memex-portal-deployment-745df44fc8-gtrfd fail: ModelContextProtocol.Server.McpServer[1433779783]
          "search_chunks" threw an unhandled exception.
          System.InvalidOperationException: An exception was thrown while activating MeshWeaver.ContentCollections.Indexing.IChunkedContentVectorStore.
           ---> Autofac.Core.DependencyResolutionException: An exception was thrown while activating MeshWeaver.ContentCollections.Indexing.IChunkedContentVectorStore.
           ---> System.InvalidOperationException: The requested service 'MeshWeaver.Hosting.Embeddings.IEmbeddingProvider' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.
          
          See https://autofac.rtfd.io/help/service-not-registered for more info.
           ---> Autofac.Core.Registration.ComponentNotRegisteredException: The requested service 'MeshWeaver.Hosting.Embeddings.IEmbeddingProvider' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.
          
          See https://autofac.rtfd.io/help/service-not-registered for more info.
             at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetRequiredService(Type serviceType)
             --- End of inner exception stack trace ---
             at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetRequiredService(Type serviceType)
             at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
             at MeshWeaver.ContentCollections.Indexing.PostgreSql.PostgreSqlContentIndexingExtensions.<>c__1`1.<AddPostgreSqlContentIndexing>b__1_0(IServiceProvider sp) in /home/runner/work/MeshWeaver/MeshWeaver/src/MeshWeaver.ContentCollections.Indexing.PostgreSql/PostgreSqlContentIndexingE…[truncated]
    2026-08-18 11:42:40Z memex-portal-deployment-745df44fc8-drjtp fail: ModelContextProtocol.Server.McpServer[1433779783]
          "search_chunks" threw an unhandled exception.
          System.InvalidOperationException: An exception was thrown while activating MeshWeaver.ContentCollections.Indexing.IChunkedContentVectorStore.
           ---> Autofac.Core.DependencyResolutionException: An exception was thrown while activating MeshWeaver.ContentCollections.Indexing.IChunkedContentVectorStore.
           ---> System.InvalidOperationException: The requested service 'MeshWeaver.Hosting.Embeddings.IEmbeddingProvider' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.
          
          See https://autofac.rtfd.io/help/service-not-registered for more info.
           ---> Autofac.Core.Registration.ComponentNotRegisteredException: The requested service 'MeshWeaver.Hosting.Embeddings.IEmbeddingProvider' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.
          
          See https://autofac.rtfd.io/help/service-not-registered for more info.
             at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetRequiredService(Type serviceType)
             --- End of inner exception stack trace ---
             at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetRequiredService(Type serviceType)
             at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
             at MeshWeaver.ContentCollections.Indexing.PostgreSql.PostgreSqlContentIndexingExtensions.<>c__1`1.<AddPostgreSqlContentIndexing>b__1_0(IServiceProvider sp) in /home/runner/work/MeshWeaver/MeshWeaver/src/MeshWeaver.ContentCollections.Indexing.PostgreSql/PostgreSqlContentIndexingE…[truncated]
    
  3. rbuergi commented on Sep 17, 2026

    @rbuergi
    Contributor

    Re-closed — the reopen above was on stale evidence (#4577).

    The recurrence bot reopened this at 2026-09-17T07:51:47Z under the headline "this fault is happening again", but the occurrence its own comment cites is OLDER than the close it reverted:

    the bot's Last seen: the close it reverted
    2026-08-18 11:42:40Z 2026-08-25T19:46:53Z

    So the counter moved, not the clock — the fault's newest occurrence predates the close, which is the one thing "still happening" has to mean. Root cause and fix: LogIncidentFiler.Reopen reopened on the sole condition that the issue was closed, while the comment-debt clock pays a final count for incidents whose fault has stopped (the fix, Systemorph/MeshWeaver.Plugins#2014, is written but NOT yet merged — it makes a reopen require incident.LastSeen > issue.ClosedAt).

    This restores the close exactly as it stood; nothing is asserted about the defect itself. If the fault happens again, the next occurrence postdates this close and reopens the issue on evidence that means what it says.

    One of 53 issues whose reopen was measured stale (129 bot reopens on 2026-09-17, 125 of them inside the 07:51-07:53Z sweep; 76 postdate their close and were left open). Measured and re-closed 2026-09-17 by Claude Opus 5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions