• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Returntype erroring on one CF server and not another

Explorer ,
Nov 20, 2020 Nov 20, 2020

Copy link to clipboard

Copied

Hi all. I've been running our application on ColdFusion 2018 locally with hotfix 9 installed, and ColdFusion 11 running on another server. The method below, despite the fact that it actually returns a string rather than the specified "boolean", has been running without error for a couple of months on both of these servers.

<cffunction name="getFirstTwoIpOctets" returntype="boolean">
        <cfargument name="ipIn" type="string" />

        <cfscript>
        firstTwoIpOctets = "";
        if (reFind("^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$", arguments.ipIn)) {
            firstTwoIpOctets = listGetAt(arguments.ipIn, 1, ".") & "." & listGetAt(arguments.ipIn, 2, ".");
        }
        return firstTwoIpOctets;
        </cfscript>
</cffunction>

Yesterday, we set up a new ColdFusion 2018 server with hotfix 10. On this server, the erroneous return type of boolean now throws an error. Can anyone tell me why an error would be thrown on the new server and not the older ones? Is it related to the extra hotfix on the new server, or possibly due to a ColdFusion administrator setting? Obviously it would be a simple thing to correct the return type on this method, but its presence could signal the potential for many other errors throughout the large site that I support.

TOPICS
Server administration

Views

260

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 20, 2020 Nov 20, 2020

Copy link to clipboard

Copied

My first suspicion would be an admin setting, yes, rather than a change due to the update. You are saying this is on a new machine, right, so you/someone may not have brought over all the same settings.

 

And yes, there is one in the cf admin which may be the ticket, in the first settings page to "disable cfc type checking". Try that on for size and let us know how it goes. 🙂 You may need to restart cf, if it doesn't work at first. 

 

If that's not it, there are a few ways to compare cf admin settings between two instances, whether on the same or different machines. I did a preso on that a couple months ago, available at carehart.org/presentations (video or slides alone (which I need to turn into a blog for easier findimg/reading), and a couple could be done by you in just a few minute, if that would help confirm or find others things. 

 


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 20, 2020 Nov 20, 2020

Copy link to clipboard

Copied

Thank you for the idea, Charlie. Unfortunately, the "disable cfc type checking" doesn't seem to be the issue. Its checkbox was already unchecked in my local administrator, where no error was being thrown. For kicks, I checked the checkbox, submitted, and restarted cf server before testing again, and that didn't throw the error either. I don't have access to the new server's administrator where the issue is occurring, but I assume that if the checkbox makes no difference on my local machine, then it won't make a differnce on the new server either.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Nov 20, 2020 Nov 20, 2020

Copy link to clipboard

Copied

Hmm, maybe that setting is only for CFCs and not for functions in general?

If you compared your server settings as described by Charlie and found nothing useful you may need to reach out to Adobe to get an authoratative answer as to whether CF has been updated to be more strict about return type checking.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Nov 20, 2020 Nov 20, 2020

Copy link to clipboard

Copied

Maybe I'm reading your code incorrectly, but your function is supposed to return a boolean value and yet your firstTwoIpOctets variable is returning a string.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 20, 2020 Nov 20, 2020

Copy link to clipboard

Copied

EddieLotter - Yes, that's true. My post was about why an error related to that bad returntype is thrown on one server but not another.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Nov 20, 2020 Nov 20, 2020

Copy link to clipboard

Copied

Ah, yes, then Charlie's answer is probably what you're looking for. 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 22, 2020 Nov 22, 2020

Copy link to clipboard

Copied

Hi Dordrecht,

The reason for that is simple. In a word: coincidence.

 

Your function checks if the argument consists of the pattern {ddd}.{ddd}.{ddd}.{ddd}, where each {ddd} group consists of 1 to 3 digits. For example, it picks out arguments such as

 

1.22.33.4

01.234.567.8

123.45.678.90

 

and so on. The function then extracts and returns the first 2 groups. Hence, for these sample arguments, the respective return values will be 

 

"1.22"

"01.234"

"123.45"

 

Now comes the crux of the argument. In ColdFusion, a numeric type is likewise a boolean. So each of these return types is a boolean. You can test this:

 

<cfoutput>
isboolean("1.22"): #isboolean("1.22")#<br>
isboolean("01.234"): #isboolean("01.234")#<br>
isboolean("123.45"): #isboolean("123.45")#
</cfoutput>

 

It's just coincidence that, in your test on ColdFusion 2018 Update 10, the function returned a non-numeric string. Whereas, on ColdFusion 2018 Update 9 and ColdFusion 11 the function never had to return a non-numeric string.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 23, 2020 Nov 23, 2020

Copy link to clipboard

Copied

LATEST

BKBK - Yes, that sounds like a realistic possibility. Possibly a valid IP address is not even being found and so the empty string is being evaluated. I'll do some research when I can next get access to that server, then report back here. Thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation