Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding check for service and instances count. #10741

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

RohitRanjanMS
Copy link
Member

Adding a check in the CreateChildContainer method to validate the counts of services and instances. Validation ensures that the number of services matches the number of instances, preventing runtime errors when processing them together. Some applications are encountering the following error, and this change will provide additional logs to aid in investigating the issue.

System.ArgumentOutOfRangeException : Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
at System.ThrowHelper.ThrowArgumentOutOfRange_IndexMustBeLessException()
at System.SZArrayHelper.get_Item[T](Int32 index)
at System.Linq.Enumerable.ElementAt[TSource](IEnumerable`1 source,Int32 index)
at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.ServiceProviderExtensions.CreateChildContainer(IServiceProvider serviceProvider,IServiceCollection serviceCollection)
at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.JobHostScopedServiceProviderFactory.CreateServiceProvider(IServiceCollection services)
at //src/WebJobs.Script.WebHost/DependencyInjection/JobHostScopedServiceProviderFactory.cs : 68
at Microsoft.Extensions.Hosting.HostBuilder.InitializeServiceProvider()
at Microsoft.Extensions.Hosting.HostBuilder.Build()
at async Microsoft.Azure.WebJobs.Script.WebHost.WebJobsScriptHostService.UnsynchronizedStartHostAsync(ScriptHostStartupOperation activeOperation,Int32 attemptCount,JobHostStartupMode startupMode)
at /
/src/WebJobs.Script.WebHost/WebJobsScriptHostService.cs : 346

Sample log

Mismatch detected for type Microsoft.AspNetCore.Mvc.ApplicationModels.IPageApplicationModelProvider:
services.Count = 6, instances.Count = 5
Services:
Microsoft.AspNetCore.Mvc.ApplicationModels.IPageApplicationModelProvider (Singleton),
Microsoft.AspNetCore.Mvc.ApplicationModels.IPageApplicationModelProvider (Singleton),
Microsoft.AspNetCore.Mvc.ApplicationModels.IPageApplicationModelProvider (Singleton),
Microsoft.AspNetCore.Mvc.ApplicationModels.IPageApplicationModelProvider (Singleton),
Microsoft.AspNetCore.Mvc.ApplicationModels.IPageApplicationModelProvider (Singleton),
Microsoft.AspNetCore.Mvc.ApplicationModels.IPageApplicationModelProvider (Singleton)
Instances:
Microsoft.AspNetCore.Mvc.ApplicationModels.DefaultPageApplicationModelProvider,
Microsoft.AspNetCore.Mvc.ApplicationModels.AutoValidateAntiforgeryPageApplicationModelProvider,
Microsoft.AspNetCore.Mvc.ApplicationModels.AuthorizationPageApplicationModelProvider,
Microsoft.AspNetCore.Mvc.ApplicationModels.TempDataFilterPageApplicationModelProvider,
Microsoft.AspNetCore.Mvc.ApplicationModels.ViewDataAttributePageApplicationModelProvider

This will help investigate

Issue describing the changes in this PR

resolves #issue_for_this_pr

Pull request checklist

IMPORTANT: Currently, changes must be backported to the in-proc branch to be included in Core Tools and non-Flex deployments.

  • Backporting to the in-proc branch is not required
    • Otherwise: Link to backporting PR
  • My changes do not require documentation changes
    • Otherwise: Documentation issue linked to PR
  • My changes should not be added to the release notes for the next release
    • Otherwise: I've added my notes to release_notes.md
  • My changes do not need to be backported to a previous version
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • My changes do not require diagnostic events changes
    • Otherwise: I have added/updated all related diagnostic events and their documentation (Documentation issue linked to PR)
  • I have added all required tests (Unit tests, E2E tests)

Additional information

Additional PR information

@RohitRanjanMS RohitRanjanMS requested a review from a team as a code owner January 14, 2025 18:08
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.

1 participant