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

Cannot access child value on Newtonsoft.Json.Linq.JValue in OrchardCore #795

Closed
jptissot opened this issue Nov 3, 2020 · 1 comment · Fixed by #796
Closed

Cannot access child value on Newtonsoft.Json.Linq.JValue in OrchardCore #795

jptissot opened this issue Nov 3, 2020 · 1 comment · Fixed by #796
Labels

Comments

@jptissot
Copy link

jptissot commented Nov 3, 2020

An unhandled exception has occurred while executing the request.
System.InvalidOperationException: Cannot access child value on Newtonsoft.Json.Linq.JValue.
   at Jint.Runtime.Descriptors.Specialized.IndexDescriptor.get_CustomValue()
   at Jint.Native.Object.ObjectInstance.UnwrapJsValue(PropertyDescriptor desc, JsValue thisObject)
   at Jint.Native.Object.ObjectInstance.Get(JsValue property, JsValue receiver)
   at Jint.Runtime.TypeConverter.OrdinaryToPrimitive(ObjectInstance input, Types hint)
   at Jint.Runtime.TypeConverter.ToPrimitive(JsValue input, Types preferredType)
   at Jint.Runtime.Interpreter.Expressions.JintExpression.EqualUnlikely(JsValue x, JsValue y)
   at Jint.Runtime.Interpreter.Expressions.JintExpression.Equal(JsValue x, JsValue y)
   at Jint.Runtime.Interpreter.Expressions.JintBinaryExpression.EqualBinaryExpression.EvaluateInternal()
   at Jint.Runtime.Interpreter.Expressions.JintBinaryExpression.GetValue()
   at Jint.Runtime.Interpreter.Statements.JintIfStatement.ExecuteInternal()
   at Jint.Runtime.Interpreter.JintStatementList.Execute()
   at Jint.Engine.Execute(Script program)
   at OrchardCore.Scripting.JavaScript.JavaScriptEngine.Evaluate(IScriptingScope scope, String script) in C:\projects\orchardcore\src\OrchardCore\OrchardCore.Scripting.JavaScript\JavaScriptEngine.cs:line 47
   at OrchardCore.Scripting.DefaultScriptingManager.Evaluate(String directive, IFileProvider fileProvider, String basePath, IEnumerable`1 scopedMethodProviders) in C:\projects\orchardcore\src\OrchardCore\OrchardCore.Infrastructure\Scripting\DefaultScriptingManager.cs:line 45

See OrchardCMS/OrchardCore#7452
and OrchardCMS/OrchardCore#7485

@jptissot jptissot changed the title Issue with Newtonsoft.Json in OrchardCore Cannot access child value on Newtonsoft.Json.Linq.JValue in OrchardCore Nov 3, 2020
@lahma
Copy link
Collaborator

lahma commented Nov 4, 2020

I had a quick look and I think this might be the reason:

0f2c39b#diff-cb9f1edd4924c5cce48293a371cbf0f53cfec3693d40c0657c7264f7e1b4b40dL100-L103

We used to swallow this kind of exception and just return Undefined. So probably wasn't working correctly before, now just manifesting the the error. And the root cause is Jint's ToPrimitive handling when it tries to find Symbol from object attributes and JValue doesn't like that at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants