structKeyTranslate(server, true) throws an errror

Description

https://www.carehart.org/blog/client/index.cfm/2021/4/5/Confirming-ColdFusions-Java-version-via-CFML-code/

https://trycf.com/gist/d3c38621cbeca954e33eb5024b2974cd/lucee5?theme=monokai

throws an error

lucee.runtime.exp.ExpressionException: key [JAVA] doesn't exist at lucee.runtime.type.util.StructSupport.invalidKey(StructSupport.java:67) at lucee.runtime.type.scope.util.SystemPropStruct.get(SystemPropStruct.java:48) at lucee.runtime.util.VariableUtilImpl.get(VariableUtilImpl.java:278) at lucee.runtime.util.VariableUtilImpl.getCollection(VariableUtilImpl.java:272) at lucee.runtime.PageContextImpl.getCollection(PageContextImpl.java:1482) at

So I thought I'd try `StructKeyTranslate`

https://trycf.com/gist/ff20fe4e7d01931f30d03cea45027dca/lucee5?theme=monokai

throws

Lucee.runtime.exp.ExpressionException: Can't cast Complex Object Type Struct to String at lucee.runtime.type.util.StructSupport.castToString(StructSupport.java:202) at lucee.runtime.op.Caster.toString(Caster.java:1923) at lucee.runtime.type.scope.util.SystemPropStruct.set(SystemPropStruct.java:71) at lucee.runtime.functions.struct.StructKeyTranslate.touch(StructKeyTranslate.java:124) at lucee.runtime.functions.struct.StructKeyTranslate.translate(StructKeyTranslate.java:113) at lucee.runtime.functions.struct.StructKeyTranslate.translate(StructKeyTranslate.java:67) at lucee.runtime.functions.struct.StructKeyTranslate.translate(StructKeyTranslate.java:74) at lucee.runtime.functions.struct.StructKeyTranslate.translate(StructKeyTranslate.java:64) at lucee.runtime.functions.struct.StructKeyTranslate.translate(StructKeyTranslate.java:74) at lucee.runtime.functions.struct.StructKeyTranslate.translate(StructKeyTranslate.java:64) at lucee.runtime.functions.struct.StructKeyTranslate.call(StructKeyTranslate.java:50) at lucee.runtime.functions.struct.StructKeyTranslate.call(StructKeyTranslate.java:46) at

Environment

None

Activity

Show:

Pothys - MitrahSoft 18 May 2021 at 13:51

Ok , I only asked for about workaround.

Zac Spitzer 18 May 2021 at 13:40

not sure what you’re asking me?

work arounds are great, this task was about avoiding needing to use them

Pothys - MitrahSoft 18 May 2021 at 11:20

Did you check my above comment? Please check and report here back.

Pothys - MitrahSoft 7 April 2021 at 08:16

I've checked this ticket and confirmed the issue happened on lucee latest version 5.3.8.163-SNAPSHOT also. If the struct key is dot-separated, lucee throws an error while using dot notation to get value. Seems ACF works fine and returns the value for the key. Using bracket notation(server.system.properties[ "java.home" ]) is works fine lucee too.

Using server scope in structKeyTranslate() with deepTranslation = true throws an error like Can't cast Complex Object Type Struct to String. Because the server is a scope, not an ordinary struct.

workaround for this

Details

Assignee

Reporter

Priority

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Created 5 April 2021 at 17:04
Updated 18 May 2021 at 15:28