episerver / foundation-mvc-cms

Apache License 2.0
17 stars 27 forks source link

ISettingsService fails when none of SiteDefinition.SiteUrl is valid #119

Open giangnb opened 2 years ago

giangnb commented 2 years ago

Steps to reproduce:

  1. Set up site, runs at localhost:5000 (default)
  2. Go to CMS admin, manage websites and change all host name to a non-existing domain, except wildcard host
  3. Back to edit mode at localhost:5000

Observed error: System.NullReferenceException: Object reference not set to an instance of an object. at Foundation.Features.Settings.ButtonBackgroundColorSelectionFactory.GetSelections(ExtendedMetadata metadata) in ...\Src\Foundation\Features\Settings\CollectionSettings.cs:line 122 at EPiServer.Shell.UI.Rest.DefaultMetadataStoreModelCreator.GetSelections(ExtendedMetadata metadata, MetadataStoreModel metadataDTO, ISelectionFactory[] selectionFactories) at EPiServer.Shell.UI.Rest.DefaultMetadataStoreModelCreator.CreateFromModelMetadata(ExtendedMetadata metadata, LocalizationService localizationService, UIDescriptorRegistry uiDescriptorRegistry, ISelectionFactory[] selectionFactories, Boolean alwaysCreateChildProperties) at EPiServer.Shell.UI.Rest.DefaultMetadataStoreModelCreator.ExtractMetadataFromProperties(ExtendedMetadata metadata, MetadataStoreModel MetadataStoreModel, LocalizationService localizationService, UIDescriptorRegistry uiDescriptorRegistry, ISelectionFactory[] selectionFactories) at EPiServer.Shell.UI.Rest.DefaultMetadataStoreModelCreator.CreateFromModelMetadata(ExtendedMetadata metadata, LocalizationService localizationService, UIDescriptorRegistry uiDescriptorRegistry, ISelectionFactory[] selectionFactories, Boolean alwaysCreateChildProperties) at EPiServer.Shell.UI.Rest.DefaultMetadataStoreModelCreator.Create(ExtendedMetadata metadata) at EPiServer.Shell.UI.Rest.MetadataStore.Get(String id, String modelAccessor) at lambda_method814(Closure , Object , Object[] ) Suggestion: Needs null check or fault-tolerance logic.

image

daniel-isaacs commented 2 years ago

@giangnb Could you please confirm this solves the issue for you (and close this if so)? Thanks!