Skip to content

Register ITargetScalerErrorRepository in AddCommonScaleServices and make public#3204

Open
alrod wants to merge 1 commit into
devfrom
users/alrod/fix-targetscaler-registration
Open

Register ITargetScalerErrorRepository in AddCommonScaleServices and make public#3204
alrod wants to merge 1 commit into
devfrom
users/alrod/fix-targetscaler-registration

Conversation

@alrod
Copy link
Copy Markdown
Member

@alrod alrod commented May 15, 2026

Summary

Fix missing DI registration in AddCommonScaleServices and make ITargetScalerErrorRepository public so external consumers can implement it directly.

Problem

SDK 3.0.46 (PR #3191) introduced ITargetScalerErrorRepository as a required dependency of ScaleManager. However, the TryAddSingleton registration was only added in AddWebJobs(). Callers using ConfigureWebJobsScale (e.g. Scale Controller) go through AddWebJobsScale -> AddCommonScaleServices, which was missing this registration, causing:

Unable to resolve service for type 'ITargetScalerErrorRepository'
while attempting to activate 'ScaleManager'

Making the interface public allows Scale Controller to provide its own in-memory implementation that tracks errored target scalers within the process lifetime, so broken scalers fall back to incremental monitoring without retrying every cycle.

Changes

  • AddCommonScaleServices: Add TryAddSingleton for ITargetScalerErrorRepository so all scale host scenarios have a safe default
  • ITargetScalerErrorRepository: Change from internal to public so external consumers can implement it directly
  • PublicSurfaceTests: Add ITargetScalerErrorRepository to expected public types

Testing

  • All existing tests pass including PublicSurfaceTests

@alrod alrod force-pushed the users/alrod/fix-targetscaler-registration branch from ae3dc4c to 163e603 Compare May 15, 2026 21:49
…ake public

ScaleManager now requires ITargetScalerErrorRepository (added in 3.0.46),
but the registration was only added in AddWebJobs(). Callers using
ConfigureWebJobsScale (e.g. Scale Controller) go through AddWebJobsScale
-> AddCommonScaleServices, which was missing this registration, causing:

  Unable to resolve service for type
  'ITargetScalerErrorRepository' while attempting to activate
  'ScaleManager'

Changes:
- Add TryAddSingleton<ITargetScalerErrorRepository, NullTargetScalerErrorRepository>
  to AddCommonScaleServices so all scale host scenarios work.
- Make ITargetScalerErrorRepository and NullTargetScalerErrorRepository public
  so external consumers (Scale Controller) can implement the interface directly
  without reflection-based DispatchProxy workarounds.

Co-authored-by: Dobby <dobby@microsoft.com>
@alrod alrod force-pushed the users/alrod/fix-targetscaler-registration branch from 163e603 to 90bf7aa Compare May 15, 2026 21:51
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