When committing events to the event store, the IEventStore from Vanir doesn't respect the current Tenant-ID set in the header.
Error from runtime:
runtime-mymicroservice_1 | warn: Dolittle.Runtime.Events.Store.EventStoreService[0]
runtime-mymicroservice_1 | Error committing events
runtime-mymicroservice_1 | Autofac.Core.DependencyResolutionException: An exception was thrown while activating λ:System.Object -> Dolittle.Runtime.Events.Store.MongoDB.EventStore -> λ:Dolittle.Runtime.Events.Store.MongoDB.Streams.IStreams -> λ:Dolittle.Runtime.Events.Store.MongoDB.DatabaseConnection -> λ:Dolittle.Runtime.ResourceTypes.Configuration.IConfigurationFor`1[[Dolittle.Runtime.Events.Store.MongoDB.EventStoreConfiguration, Dolittle.Runtime.Events.Store.MongoDB, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].
runtime-mymicroservice_1 | ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
runtime-mymicroservice_1 | ---> Dolittle.Runtime.ResourceTypes.Configuration.MissingResourceConfigurationForTenant: Tenant with id '508c1745-5f2a-4b4c-b7a5-2fbb1484346d' does not have a any resource configurations'
runtime-mymicroservice_1 | at Dolittle.Runtime.ResourceTypes.Configuration.ResourceConfigurationsByTenantProvider.ThrowIfMissingResourceConfigurationForTenant(TenantId tenantId) in /app/Source/ResourceTypes.Configuration/ResourceConfigurationsByTenantProvider.cs:line 83
runtime-mymicroservice_1 | at Dolittle.Runtime.ResourceTypes.Configuration.ResourceConfigurationsByTenantProvider.GetResourceConfiguration(TenantId tenantId, ResourceType resourceType) in /app/Source/ResourceTypes.Configuration/ResourceConfigurationsByTenantProvider.cs:line 58
runtime-mymicroservice_1 | at Dolittle.Runtime.ResourceTypes.Configuration.ResourceConfigurationsByTenantProvider.ConfigurationFor(Type configurationType, TenantId tenantId, ResourceType resourceType) in /app/Source/ResourceTypes.Configuration/ResourceConfigurationsByTenantProvider.cs:line 41
runtime-mymicroservice_1 | at Dolittle.Runtime.ResourceTypes.Configuration.ResourceConfigurationsByTenantProvider.ConfigurationFor[T](TenantId tenantId, ResourceType resourceType) in /app/Source/ResourceTypes.Configuration/ResourceConfigurationsByTenantProvider.cs:line 52
runtime-mymicroservice_1 | at Dolittle.Runtime.ResourceTypes.Configuration.TenantResourceManager.GetConfigurationFor[T](TenantId tenantId) in /app/Source/ResourceTypes.Configuration/TenantResourceManager.cs:line 35
runtime-mymicroservice_1 | at Dolittle.Runtime.ResourceTypes.Configuration.ConfigurationFor`1..ctor(ITenantResourceManager tenantResourceManager, IExecutionContextManager executionContextManager) in /app/Source/ResourceTypes.Configuration/ConfigurationFor.cs:line 24
runtime-mymicroservice_1 | --- End of inner exception stack trace ---
runtime-mymicroservice_1 | at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
runtime-mymicroservice_1 | at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
runtime-mymicroservice_1 | at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture)
runtime-mymicroservice_1 | at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
runtime-mymicroservice_1 | at System.Activator.CreateInstance(Type type, Object[] args)
runtime-mymicroservice_1 | at Dolittle.Runtime.DependencyInversion.Autofac.Tenancy.TypeActivator.CreateInstanceFor(IComponentContext context, Type service, Type type) in /app/Source/DependencyInversion.Autofac/Tenancy/TypeActivator.cs:line 52
runtime-mymicroservice_1 | at Dolittle.Runtime.DependencyInversion.Autofac.Tenancy.InstancesPerTenant.Resolve(IComponentContext context, Binding binding, Type service) in /app/Source/DependencyInversion.Autofac/Tenancy/InstancesPerTenant.cs:line 79
runtime-mymicroservice_1 | at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
runtime-mymicroservice_1 | at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters, Object& decoratorTarget)
runtime-mymicroservice_1 | --- End of inner exception stack trace ---
runtime-mymicroservice_1 | at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters, Object& decoratorTarget)
runtime-mymicroservice_1 | at Autofac.Core.Resolving.InstanceLookup.Execute()
runtime-mymicroservice_1 | at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest request)
runtime-mymicroservice_1 | at Autofac.Core.Resolving.ResolveOperation.Execute(ResolveRequest request)
runtime-mymicroservice_1 | at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance)
runtime-mymicroservice_1 | at Autofac.ResolutionExtensions.ResolveOptionalService(IComponentContext context, Service service, IEnumerable`1 parameters)
runtime-mymicroservice_1 | at Dolittle.Runtime.Hosting.Microsoft.ServiceProviderContainer.Get[T]() in /app/Source/Hosting.Microsoft/ServiceProviderContainer.cs:line 26
runtime-mymicroservice_1 | at Dolittle.Runtime.DependencyInversion.Autofac.FactoryForRegistrationSource.FactoryForClass`1.Activate[TType]() in /app/Source/DependencyInversion.Autofac/FactoryForRegistrationSource.cs:line 64
runtime-mymicroservice_1 | at Dolittle.Runtime.Events.Store.EventStoreService.Commit(CommitEventsRequest request, ServerCallContext context) in /app/Source/Events.Store/EventStoreService.cs:line 53
It looks like the TenantId used in the `IEventStore´ is hardcoded. Shouldn't this resolve to the event store for the tenant in the current execution context, and set it on a per request level? Alternatively, this may need to be read from the resource configuration, but I'm not sure how this would work if there were multiple tenants.
When committing events to the event store, the IEventStore from Vanir doesn't respect the current Tenant-ID set in the header.
Error from runtime:
I suspect it has something to do with the hardcoded ID used for the IEventStore registration in the container. https://github.com/dolittle-entropy/vanir/blob/f0baeff3aa13721facb3abb18f82d49656c68344/Source/typescript/backend/dolittle/index.ts#L50-L52
It looks like the
TenantId
used in the `IEventStore´ is hardcoded. Shouldn't this resolve to the event store for the tenant in the current execution context, and set it on a per request level? Alternatively, this may need to be read from the resource configuration, but I'm not sure how this would work if there were multiple tenants.