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

Code that worked for years suddenly glitches - CF2021 > CF2023

LEGEND ,
Nov 04, 2025 Nov 04, 2025

Hello, everyone.

 

About a week ago, our SA and DBA started a migration from CF2021 to CF2023, we are experiencing a couple of odd issues, and the weird thing is - it's limited to just one project.  No other projects are experiencing these issues.  The issue is in our custom built Workflow application.

 

One issue is with setting an identifier for a user using data pulled from the user's Common Access Card (CAC).  We are pulling the DoDID (lastName.firstName.middleName[.cadenceName].EPIDnumber) and I'm getting the 10 digit EPID from this string that is in the CGI scope.

 

<cfset session.userepid = REMATCH("\d{10}",cgi.SSL_CLIENT_S_DN_CN)[1] />

The number that is in the DoDID can be either a 10 digit number, or a 16 digit number.  So I'm looking for all 10 digit numbers and taking the first position in the array as the desired number.  This is the actual EPID.  But I'm getting an error that position 1 of the array doesn't exist.  I can output the whole DoDID before that point, do the rematch and get an array length of 1 from my CAC, and abort the page - it works.  But as soon as I comment out that added code and abort, it gets to the above line in the code section and throws an error saying that it can't find anything in the array.  Stops processing.

 

Another issue we are having has to do with DateDiff.  For years, we've been converting the dates pulled from the database using to_char(dateObject, 'YYYY-MM-DD').  But we are getting an error stating that the value supplied to the cfoutput is "unspecified or invalid".  Dumping the data shows all dates in the query are proper dates.  Only thing I can think of is maybe CF2023 handles empty dates differently than CF2021 does??

 

Any thoughts appreciated.

 

V/r,

 

WolfShade

 

UPDATE:  My DBA suggested I use ParseDateTime() around the values.  I did, and the first date wasn't an issue - it worked - but the second date threw an error for ParseDateTime() (no end date had been entered, and CF didn't like '' as a value.)  I placed a cfif around it so it would process the second date ONLY if there was a value other than '', and that worked.

 

But when it got to DateDiff, that error happened.  Apparently it doesn't like that second date being a blank/null.  This has been working with no problem for years.  Why it suddenly flips out over a blank date ...

174
Translate
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
Enthusiast ,
Nov 04, 2025 Nov 04, 2025

@WolfShade for your DateDiff issue, there is a breaking change introduced in CF2021 with date masks. The uppercase D now means day of year, instead of day of month. Change your date mask to lowercase to fix. Details here: https://www.petefreitag.com/blog/coldfusion-compatibility-scan/ 

 

Since you are already on CF2021, perhaps you had specified the JVM argument: -Dcoldfusion.datemask.useDasdayofmonth=true to override this behaviour. 

Translate
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
LEGEND ,
Nov 04, 2025 Nov 04, 2025

Hi, @pete_freitag !  

 

It's possible that the SA may have added that JVM argument.. I'll ask.

 

Meanwhile, I'm going to update my original post.  There has been minor progress.  😄

 

WolfShade

Translate
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 04, 2025 Nov 04, 2025
  • "Position 1 of the array doesn't exist"
    My guess is that sometimes cgi.SSL_CLIENT_S_DN_CN does not contain a ten-digit substring. You can verify this by using try/catch.
    In the following example, when the error occurs, the CGI scope is dumped - out of the user's sight - as an HTML file which you can examine later.
    <cftry>
    	<cfset session.userepid = REMATCH("\d{10}",CGI.SSL_CLIENT_S_DN_CN)[1] />
    	<cfcatch type="any">
    		<cfdump var="#CGI#" label="CGI dump: implies CGI.SSL_CLIENT_S_DN_CN does not contain ten-digit substring" format="html" output="#server.coldfusion.rootDir#\logs\CGI.SSL_CLIENT_S_DN_CN.dump.html">
    	</cfcatch>
    </cftry>
    ​

    Is cgi.SSL_CLIENT_S_DN_CN then what you expected

  • Invalid date and datetime values
    The database may format dates and datetimes differently from your application. Even ColdFusion code based on different locales do represent dates differently. 
    So, I'd say the moral is: validate date values and datetime values before using them, especially if they're coming from another party
    Some relevant validation functions:
    IsDate
    IsValid
    LSIsDate
     
Translate
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
LEGEND ,
Nov 05, 2025 Nov 05, 2025

Hi, @BKBK!

 

I have verified that my EPID is, indeed, in my DoDID being returned by cgi.SSL_CLIENT_S_DN_CN.  I was able to output my DoDID to the screen, perform the REMATCH against it using "\d{10}" and got an array length of 1.  Outputting the first position of the array then aborting any further page processing shows my 10 digit EPID.  It's there.  I just can't understand why it doesn't see it when trying to save it to a session variable, on the very next line (once the abort has been commented out.)

 

As far as the date goes, the to_char() is formatting the date as YYYY-MM-DD and passing the string version to the DateDiff() function.  This worked fine under CF2021.  And what's more perplexing is that it worked under CF2023 until late last week.  Thu/Fri, it started giving us fits, and only on this one project.  No other projects have been negatively affected.

 

The documentation for DateDiff() is giving a mixed message as far as what to provide DateDiff() - first example passes string value dates (date1 = "2018-09-25"), the second example passes a date object (Date1 = "{ts '2018-11-15 12:13:50'}").  I've tried both, no success.  I've tried removing the to_char() from the query, no success.

 

As far as I can tell, the only difference between this project and other projects is - this uses application.cfm, not .cfc.  No one bothered updating to application.cfc because it just worked.

 

V/r,

 

WolfShade

 

UPDATE:  I just checked the database, and the begin and end date columns are formatting as YYYY-MM-DD, some with actual hours/minutes/seconds/ms, others with 00:00:00.0.  It's been this way since before I started working here in 2012.

Translate
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 05, 2025 Nov 05, 2025

I've read all the replies so far. If you remain stumped after doing what bkbk and Pete have suggested, then please do this:

  1. Dump cgi.SSL_CLIENT_S_DN_CN right before the code that's failing. Is it indeed an array? And is array element 1 what you'd expect?
  2. Dump to_char(dateObject, 'YYYY-MM-DD') and separately just dateobject just before the line using those. Do those have what you expect. 
  3. Please don't presume other similar dumps in other places prove "you've done it already": do those, right there (to a file if you must). Let us see the value of the date dumps. 
  4. If you remain stumped, you may be presuming there's a problem with CF or perhaps your application.cfc/cfm. In that case, please create a standalone few-line program that demonstrates the problem.
  5. Then try running that on its own folder with its own empty application.cfc. Does the error/unexpected behavior persist?
  6. If so, run that code on cffiddle.org or trycf.com, both of which will let you run it against different cf versions.
  7. If it fails on them, on different versions, do you have some environment where this demo code runs well? If so, tell us it cf version and update level that is. Maybe it's on an older update (those sites don't let you try different update levels). You might want to share the few-line demo here for us to try. Some of us can test on different update levels. 

/Charlie (troubleshooter, carehart. org)
Translate
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
LEGEND ,
Nov 05, 2025 Nov 05, 2025

Hi, @Charlie Arehart!

 

If I dump cgi.SSL_CLIENT_S_DN_CN, it's a string.  My DoDID: lastName(dot)firstName(dot)middleName(dot)cadenceName(dot)EPID.  The REMATCH finds my 10 digit EPID with no issues, creating an array with a length of 1, if I abort before the line that saves it to a session variable.  I can display that EPID.  It's when I comment out that code and let it get to the part where it saves that to a session variable that it throws an exception.

 

I'll give your suggestions a shot, and even create a scratchpad file for testing.  I'll report back here with my findings.

 

Thank you.

 

V/r,

 

WolfShade

 

UPDATE:  The issue with the EPID has cleared itself up.  I changed no code regarding it.  No one has informed me that there was any config or settings change.  It just started working.  Focusing on the DateDiff issue.

Translate
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 05, 2025 Nov 05, 2025

Ah, I missed that the brackets in your original code are OUTSIDE the function. Sorry. 

 

But since you say (in the original post) that you're "getting an error that position 1 of the array doesn't exist", then instead dump the RESULT of the function. Is THAT an array? Is it indeed empty? 

 

Next, you go on to suggest that somehow the ASSIGNMENT of the function result to a session var somehow makes the assignment fail. I can't see how that could be so. (Even so, you may want to dump the session scope right before the assignment to confirm you have a valid session.) 

 

Finally you go on here to refer to differences when you comment out stuff. That's where it's so valuable to create a standalone demo, to exhibit what you're experiencing. That will help you also, to narrow down what it takes specifically to make the error, no more and no less. (And I know you're a longtime CFer also, and even help others here. I'm not meaning to be condescending with what I'm saying. It's as much for future readers following along.) 

 

Will be very interesting to hear what more you may find or share. 


/Charlie (troubleshooter, carehart. org)
Translate
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
LEGEND ,
Nov 05, 2025 Nov 05, 2025

Hi, @Charlie_Arehart!

 

I updated my earlier post.  I have no idea why it just started working with the EPID.  No idea why.

 

I'm focusing on the DateDiff() error.  I'll follow your suggestions and report my findings.

 

Thank you.

 

V/r,

 

WolfShade

 

UDPATE:  Wanted to try something before I engaged in your suggestions.

I placed a CFTRY/CFCATCH around the line that is reported as the issue, and set it to display the begin date and end date, and had to manually add a cfset for variables.diffdate (the variable that the DateDiff() value is being set to.)  Reloaded the page, and the very first record that didn't have an end date is what triggered the error.  The value of qry.end_date is "[empty string]".  Now, this I can see would not work well in a DateDiff() function.  But why did it work for so long, then suddenly start pushing [empty string] for a blank date?

Translate
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 05, 2025 Nov 05, 2025

Unless you want to leave it be with that conclusion, and since you seem to be leaning toward a change in how your different cf versions work, please proceed to create a few-line test that demonstrates what you're now suggesting is the problem. Run it locally, then run it on the public fiddles which allow you to test against past versions. 


/Charlie (troubleshooter, carehart. org)
Translate
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 06, 2025 Nov 06, 2025
quote

The value of qry.end_date is "[empty string]".  Now, this I can see would not work well in a DateDiff() function.  But why did it work for so long, then suddenly start pushing [empty string] for a blank date?


By @WolfShade

Two words: ColdFusion updates. ColdFusion's updates strive to remove ambiguous or incorrect functionality from the language. Especially in recent years. So, what was ignored or allowed in a previous update might result in an error in the current update.

Translate
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 06, 2025 Nov 06, 2025
quote

UPDATE:  The issue with the EPID hTHE as cleared itself up.  I changed no code regarding it.  No one has informed me that there was any config or settings change.  It just started working.  Focusing on the DateDiff issue.


By @WolfShade

I can guess why. It is in the nature of CGI variables that, if CGI.SOME_NONEXISTENT_VARIABLE_ABRACADABRA doesn't exist, then

<cfoutput>#CGI.SOME_NONEXISTENT_VARIABLE_ABRACADABRA#</cfoutput>

won't result in an error. That is because the value of the non-existent CGI variable is stored as "".

So my guess is, sometimes cgi.SSL_CLIENT_S_DN_CN may not exist. 
A suggestion follows immediately from there: before using the variable, validate with something like

<cfif trim(cgi.SSL_CLIENT_S_DN_CN) is not "">
</cfif>
Translate
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
LEGEND ,
Nov 05, 2025 Nov 05, 2025

Network restrictions are so tight, here.. DLP on steroids on top of steroids.  Not sure I can get to a cffiddle, or even paste code if I could.  And I'm using my personal computer to access the forum, so getting images might be difficult, but I'll see what I can do.  On top of that, my Dreamweaver keeps freezing up on me, just by switching from one file to another.  Have to force it closed, then re-open.

 

2.  Dumping the dateobject (qry.end_date) and using a try/catch to keep the page processing results in most of the records having a valid date (2025-09-03, for example) and some having [empty string] as the value.

 

4.  Copying some of the code (query, query output, etc.) into a separate folder and running that results in the same generic error page that's in the original folder.  Adding try/catch to it and dumping the end_date shows the same "[empty string]" value for a blank date, and the actual date if there is a valid date.

 

5. Yes.

 

I don't think I can run this on any cffiddle, now that I think of it, since this is pulling data from a local database.  That can't be made publicly available for querying.

 

Product version is 2023,0,16,330828.  Update level 16.

 

V/r,

 

WolfShade

Translate
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 05, 2025 Nov 05, 2025

I am proposing that you please just create a simple few-line simple example that demonstrates ONLY the problem that remains, in as few lines as possible, and WITHOUT using any variables which come from your queries or your app session scope or any previously run code. Keep it minimal, do only what's needed to cause the problem.  That might even be one line. Doing this really will help you as much as us. You're well on your way, it seems.

 

BTW, then being only a few lines, you can just type them here, as your way to then have it available when you get home (off the DOD network) to try running it in one of the fiddles. I'm trying to help you see around all the roadblocks in front of you. 🙂 

 

On that and as for Dreamweaver, finally, a rant: if someone works with CF with any regularity (more than once a week) and unless they are retiring/leaving CF in the next month, it would seem REALLY worth their time and effort to learn to use ANYTHING other than DW. 🙂 Not least of which because besides your bugginess it hasn't had CFML support in more than 10 years.

 

How about using any of the popular free VSCode (for which one can turn off MS telemtry and AI support), or the open-source vscodium alternative to it (which has no MS telemtry)? Those have current CFML support from Adobe (ColdFusion Builder...and yes, you can install CFB into codium using a vsix file) and from others.

 

Or how about Sublime, which has CFML support updated in 2025, or NotePad++ or  which at least had CFML support until some years ago? Or use any of those without the CFML support. Or heck in that case use notepad on Windows (or vim or nano on Linux), and so on.

 

I keep a list of editors, both those WITH and WITHOUT CFML support at cf411.com. The benefits DW offers most people can be provided for in about any other modern editor (though wysiwyg editing and ftp--rather than sftp--are ignored or frowned upon by most of them).


/Charlie (troubleshooter, carehart. org)
Translate
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
LEGEND ,
Nov 06, 2025 Nov 06, 2025

I thank you, Pete, and BKBK, for your time and attention to my issue.  Sadly, too many other issues that I have to focus on as a result of this upgrade.  I did manage to "band-aid" it by using a try/catch and just setting the end_date to "" if it isn't in the database.  I hate leaving it this way as it feels hackish, but my PM is frustrated that I've spent this much time on this one issue, with other issues that need attention.  This was a priority, now it's kinda fixed and not as much of a priority.  Grr..

 

As far as Dreamweaver, I agree.  Granted, I've been using Dw for all of my 25 years as a coder, and was never happy about Dw dropping CF support.  But for as long as I've been here, it's the only IDE on our ASL.  I can report that VSCode was recently added to a list of software to evaluate for security, so there's that.  And I did just recently install VSCode on my Linux Mint VM (22.2 Zara), and I'm trying to learn it.. but it's way more complex than I had assumed.  Still trying to customize it!  But I guarantee it'll take 6-8 months (minimum) for the VSCode evaluation to be complete and (hopefully) added to our ASL.

 

Sublime - tried it, hated it.  Eclipse, CFB, same.  Hated the interface, and I _especially_ despised the function in CFB that automatically built a minimum of 5 CFCs for every table in a DSN.  We had a lead developer that did that for one project, finished it, and then found employment elsewhere.  I cringe every time I have to wrench anything in that project.

 

V/r,

 

WolfShade

Translate
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 06, 2025 Nov 06, 2025
LATEST

Thanks for the update, and hope things go well.


/Charlie (troubleshooter, carehart. org)
Translate
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