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

Prevalues fail with no caption #1140

Closed
alandraper opened this issue Dec 22, 2023 · 6 comments
Closed

Prevalues fail with no caption #1140

alandraper opened this issue Dec 22, 2023 · 6 comments
Labels
release/12.2.2 release/13.0.1 state/sprint-candidate We're trying to get this in a sprint at HQ in the next few weeks type/bug

Comments

@alandraper
Copy link

alandraper commented Dec 22, 2023

Umbraco Forms 11.2.1

Adding a dropdown list and filling in the Values but not the Captions causes a null reference exception reading the form

Reproduction

Create a new form; add a dropdown; add some prevalues, but leave the "Captions" blank.

Save the form and reload the page.

The form will be unreadable and undeletable. The only way to fix it is to edit the json directly in the database.

The error is in FieldPrevalueJsonConverter.cs which seems like it needs some null reference checks

JToken jToken = JToken.Load(reader);
if (jToken is JObject jObject)
{
	return new FieldPrevalue
	{
		Value = jObject["value"].ToString(),
		Caption = jObject["caption"].ToString() // causes exception
	};
}

This item has been added to our backlog AB#36279

@AndyButland AndyButland added type/bug state/sprint-candidate We're trying to get this in a sprint at HQ in the next few weeks labels Jan 1, 2024
@AndyButland
Copy link

AndyButland commented Jan 2, 2024

Strange... I agree the code you have shown looks problematic, but in testing I don't see a problem here. Even with the caption with a value of null, the expression comes back as an empty string. In any case though we can be more defensive here and hopefully that'll sort it out for all setups.

@alandraper
Copy link
Author

It definitely causes an error. Just came across it again for a different client.

Just update a form definition in the database with the prevalues like this to see the error

    "preValues": [
        {
            "value": "1"
        },
        {
            "value": "2"
        },
        {
            "value": "3"
        },
        {
            "value": "4"
        }
    ],

@AndyButland
Copy link

What version are you on now please @alandraper where you are seeing this problem still?

@alandraper
Copy link
Author

alandraper commented Mar 13, 2024 via email

@AndyButland
Copy link

OK, so they won't have the fix I'm afraid - this was resolved in 12.2.2 and 13.0.1 as per the labels on this issue. Forms 11 (and Umbraco 11) is "end of life" now though, so we aren't planning to make further updates to that version. Ideally I think you would get them onto Umbraco 13, which is a "long-term support" version.

@alandraper
Copy link
Author

alandraper commented Mar 13, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release/12.2.2 release/13.0.1 state/sprint-candidate We're trying to get this in a sprint at HQ in the next few weeks type/bug
Projects
None yet
Development

No branches or pull requests

2 participants