UnexpectedDataType error after upgrading to the new version of Appfarm

After we have upgraded to the new version of Appfarm, runtime properties which are using Moment to work with date are causing an UnexpectedDataType error when creating a new object in Services:

Action Node failed: Create Object → UnexpectedDataTypeError: Some result from function evaluation is an object or array.

We have an object with runtime property, which is generated by function:
“return moment(datoStatusInnvilget).add(1, ‘d’);”
And when we try to create a new object in Service, we get this error:

It used to work well across the system, and we have similar setup for runtime properties in many places. Does it mean we have to rewrite it everywhere now?


It seems like it is not allowed to return a moment object to a datetime field. According to docs, this is not allowed / correct (see this article, where you are suggested to add .toJSON() to the end). So, the fix (and correct setup) if to change the function to return moment(datoStatusInnvilget).add(1,'d').toJSON()

However, the evaluation and error handling of functions in Services has been improved recently. We believe this has never worked, but in some cases has (unintentionally) not been reported as an error. We’ll investigate this one a bit more, and will post an update here if we find anything that differs from the abovementioned reason.

Thank you for reply, Kristian
It has been working for the last year or more without issues, and the date was returned correctly. And in the article you are referencing it is not stated explicitly, that toJSON() should be always used, only when we need to get UTC adjusted value (also as stated in Momentjs docs).
As we use Momentjs extensively, and the application is quite large - is it possible to find all occurrences of Momentjs? Otherwise we will need to go manually through apps/services and find where it has been used to add toJSON().

Thanks for valuable feedback. You are correct, this has been working in Services (not in Apps). The docs where not 100% clear on this requirement, and has been updated. Probably not too many affected, as most people probably have been unaware that this was possible to set up in Services.

A challenge has been registered, and we’re inspecting the timeline and whether it may be patched in a safe way. But for urgent matters, the functions must be altered to return a simple datatype (e.g. adding .toJSON() to the return statement).

Will update this post when the challenge/solution has been concluded.

1 Like

We were struggling with this same issue, several of our endpoints crashed and it took us some time to understand why. Would be nice with some kind of notification when new releases affect old code.

1 Like