umbraco / Umbraco.UIBuilder.Issues

Back office UI builder for Umbraco
3 stars 2 forks source link

Upgrading from 13.0.2 to 13.1.1 breaks configuration binding in project #96

Closed skttl closed 6 months ago

skttl commented 6 months ago

Describe the bug Don't really know how, but here goes.

We have a project with UI Builder. In that project we add some configuration through appsettings.json like

{
  "Umbraco": {
    "Community": {
      "ImageSharpRemoteImages": {
        "Settings": [
          {
            "Prefix": "/remote",
            "AllowedDomains": [ "*" ],
            "MaxBytes":  24
          }
        ]
      }
    },
}

MaxBytes is an int property in the IOptions model.

Before upgrading UI Builder this would result in IOptions having a correct value of 24 in the MaxBytes.

After upgrading, the int value from appsettings.json fails to bind, resulting in the value falling back to the default (eg. 0). This happens for all int values in IOptions models.

The above example is using a package - so you can see how the model is bound in the source code.

I've also tried with other config settings using builder.Services.Configure<MyOptions>(builder.Config.GetSection("Path:To:MyOptions")) with the same error.

Has anything changed between 13.0 and 13.1 that could cause this?

skttl commented 6 months ago

Another example, the configured port for smtp settings eg.

  "Umbraco": {
    "CMS": {
      "Content": {
        "MacroErrors": "Throw"
      },
      "Examine": {
        "LuceneDirectoryFactory": "Default"
      },
      "Global": {
        "MainDomLock": "",
        "Smtp": {
          "From": "it@ecreo.dk",
          "Host": "localhost",
          "Username": null,
          "Password": null,
          "Port": 25
        }
      },

Turns up as 0 (screenshot from Diplo God Mode) image

skttl commented 6 months ago

Just tried out the same in a shiny new blank install

Installed using this script (Diplo.GodMode is added, so the config values can be read through the backoffice)

# Ensure we have the version specific Umbraco templates
dotnet new install Umbraco.Templates::13.2.2 --force

dotnet new umbraco --force -n "13-2-2-ui-builder-config-bug" --friendly-name "Administrator" --email "admin@admin.com" --password "admin@admin.com" --development-database-type SQLite

#Add Packages
dotnet add "13-2-2-ui-builder-config-bug" package Diplo.GodMode
dotnet add "13-2-2-ui-builder-config-bug" package Umbraco.UIBuilder

dotnet run --project "13-2-2-ui-builder-config-bug"
#Running

Add some smtp settings in appsettings.json

...
  "Umbraco": {
    "CMS": {
      "Global": {
        "Id": "c0f6a079-3881-47ad-83d9-cdbdc660e2af",
        "SanitizeTinyMce": true,
        "Smtp": {
          "From": "admin@admin.com",
          "Port": 1322
        }
      },
...

Open up Umbraco, go to Settings, God Mode, Diagnostics. Find the smtp settings: image

As you can see, port is 0 here - but should have been 1322 according to appsettings.json.

acoumb commented 6 months ago

Hi @skttl ,

The issue you are experiencing is a result of a custom Udi type converter I've introduced with latest releases.

I am looking into this to work on a fix.

Thanks, Adrian

patlit commented 6 months ago

Having same issues after upgrading to 13.1.1 to day. All IOptions of type integer now returns 0 @acoumb Any idea when this will be fixed? Its causing issues for SMTP and image cache configuration and several of our IOptions usages. Do we need to downgrade UI builder? Thanks, Patrik

acoumb commented 6 months ago

Hi @skttl , @patlit ,

The issue has been fixed with the latest minor release 13.1.2.

Thank you, Adrian