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

Prefill-dictionary does not allow string containing a single quote #928

Open
rodsjo opened this issue Nov 25, 2024 · 0 comments
Open

Prefill-dictionary does not allow string containing a single quote #928

rodsjo opened this issue Nov 25, 2024 · 0 comments
Labels
kind/bug Something isn't working status/triage

Comments

@rodsjo
Copy link

rodsjo commented Nov 25, 2024

Description of the bug

Got an error when instansiating schema dat/bemanning-aarligmelding with HTTP POST simplified instansiation and this request body:

{
    "instanceOwner": {
        "partyId": null,
        "personNumber": null,
        "organisationNumber": "924713992"
    },
    "dueBefore": "2025-01-01T00:00:00.0000000",
    "visibleAfter": null,
    "prefill": {
        "Prefill.EraSourceEnvironment": "prod",
        "Prefill.KanOppretteAarligMelding": "True",
        "Prefill.ArkivSaksId": "1203228",
        "Prefill.InnsendingSvarfrist": "2025-01-01T00:00:00.0000000",
        "Prefill.YrkesskadeforsikringPolisenummer": "301738.1",
        "Prefill.YrkesskadeforsikringNavn": "S'oderberg og Partners",
        "Prefill.YrkesskadeforsikringGyldigTilDato": "2023-12-31T12:00:00.000+01:00"
    }
}

Error:

Newtonsoft.Json.JsonReaderException:
   at Newtonsoft.Json.JsonTextReader.Read (Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed)
   at Newtonsoft.Json.Linq.JToken.Parse (Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed)
   at Altinn.App.Core.Implementation.PrefillSI.LoopThroughDictionaryAndAssignValuesToDataModel (Altinn.App.Core, Version=8.3.4.142, Culture=neutral, PublicKeyToken=null)
   at Altinn.App.Core.Implementation.PrefillSI.PrefillDataModel (Altinn.App.Core, Version=8.3.4.142, Culture=neutral, PublicKeyToken=null)
   at Altinn.App.Core.Implementation.PrefillSI+<PrefillDataModel>d__13.MoveNext (Altinn.App.Core, Version=8.3.4.142, Culture=neutral, PublicKeyToken=null)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Altinn.App.Core.Internal.Process.ProcessTasks.ProcessTaskInitializer+<Initialize>d__8.MoveNext (Altinn.App.Core, Version=8.3.4.142, Culture=neutral, PublicKeyToken=null)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Altinn.App.Core.Internal.Process.EventHandlers.ProcessTask.StartTaskEventHandler+<Execute>d__4.MoveNext (Altinn.App.Core, Version=8.3.4.142, Culture=neutral, PublicKeyToken=null)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Altinn.App.Core.Internal.Process.ProcessEventHandlingDelegator+<HandleEvents>d__7.MoveNext (Altinn.App.Core, Version=8.3.4.142, Culture=neutral, PublicKeyToken=null)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Altinn.App.Core.Internal.Process.ProcessEngine+<HandleEventsAndUpdateStorage>d__11.MoveNext (Altinn.App.Core, Version=8.3.4.142, Culture=neutral, PublicKeyToken=null)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult (System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Altinn.App.Api.Controllers.InstancesController+<PostSimplified>d__21.MoveNext (Altinn.App.Api, Version=8.3.4.142, Culture=neutral, PublicKeyToken=null)

It seems that the error originate from the following line:

sourceValue = JToken.Parse($"'{source}'");

The problem is that a string value in the prefill-dict contains a single quote:

"Prefill.YrkesskadeforsikringNavn": "S'oderberg og Partners"

Steps To Reproduce

Instansiate a new schema with simplified instansiation, HTTP POST request against https://dat.apps.altinn.no/<app-name>/instances/create with a prefill-dict that contains a single quote in a text string:

{
    "instanceOwner": {
        "partyId": null,
        "personNumber": null,
        "organisationNumber": "<orgnumber>"
    },
    "dueBefore": null,
    "visibleAfter": null,
    "prefill": {
        "Foobar": "String contain'ing a single quote"
    }
}

Additional Information

Altinn.App.Core version 8.3.4

@rodsjo rodsjo added the kind/bug Something isn't working label Nov 25, 2024
@ivarne ivarne moved this to 📈 Todo in Team Apps Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working status/triage
Projects
Status: 📈 Todo
Development

No branches or pull requests

1 participant