Supressing errors from ACF when writing cross-engine CFML

There might be a simple solution for this, but I can’t seem to find it. I’m trying to write some code that will run on both ACF and Lucee. One part of it requires me to use an attribute for a tag that does not exist in CF, so I did this…

<cfif structkeyexists(server,"lucee")>
   <cfhttp url="urlhere" encodeurl="no"></cfhttp>
   <cfhttp url="urlhere"></cfhttp>

So this works fine on Lucee. On ACF, it throws an attribute validation error because “encodeurl” doesn’t exist on ACF - even though that code would never actually run on ACF.

I’ve simplified this example, but I also have other cases where this is needed as well.

I’m wondering… does anyone know if there is a setting or directive that would prevent ACF from throwing an error on Lucee-specific code?

I know this is a Lucee support board, but I thought maybe someone else might have run into this while writing cross-platform code.

I think your workaround is fine for many scenarios. With tags in particular you can often use the attributeCollection attribute to avoid attribute validation errors, so to give you an example using your code;

<cfset attrs = {}>
<cfif structkeyexists(server,"lucee")>
   <cfset attrs.encodeurl = "no">
<cfhttp url="urlhere" attributeCollection="#attrs#"></cfhttp>

That’s perfect! I knew there had to be a solution, but I couldn’t come up with it. Thank you.

I would also consider a custom tag implementation for anything like this so you can abstract it completely.

<cf_myHttp url="urlhere">

Inside cf_myHttp you do all your magic for lucee vs acf.