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

CF throws undefined var, but error email includes it

New Here ,
Aug 17, 2006 Aug 17, 2006

Copy link to clipboard

Copied

We have a sitewide error handler that emails us whenever an error occurs on a site. This error email includes cfdumps of every scope.

Frequently I receive error mails telling me that variable X is undefined in Session. So I scroll down the email to the Session scope dump, and... there's the variable. So CF thinks it doesn't exist and throws an error, but it appears in a cfdump of the session scope in the error handler. Any idea what causes this?
TOPICS
Advanced techniques

Views

373

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
LEGEND ,
Aug 17, 2006 Aug 17, 2006

Copy link to clipboard

Copied

Which version of CF?

--
Adam

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
New Here ,
Aug 17, 2006 Aug 17, 2006

Copy link to clipboard

Copied

MX 7

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 ,
Aug 17, 2006 Aug 17, 2006

Copy link to clipboard

Copied

could it be picking up session info from a different user? have you looked at the http_user_agent - is it a human user or a crawler? have noticed wierd things with our error emails and crawlers on occasion.

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
LEGEND ,
Aug 18, 2006 Aug 18, 2006

Copy link to clipboard

Copied

I have - in the past - had problems managing session variables with
constructs like this:

<cfif isDefined("session.foo")>
<cfoutput>#session.foo#</cfoutput>
</cfif>

Where the isDefined() expression was true, but the following line errored
with "variable does not exist".

It was only with session variables that this happenend.

We changed to using structKeyExists(), and the problem went away. This was
back in CFMX6x, and have never used isDefined() since, so not sure if the
problem still persists.

This does not help your situation, but is perhaps confirmation that there
is something flaky about the session scope, and how CF determines the
existence of variables in it.

I don't know how the error template stuff works... is it a separate request
(ie: are things like Application.cfm executed again?). Could the variable
somehow be getting set between the time the error is thrown and when the
<cfdump> is emailed to you?

Does the error always crop up at the same piece of code / same variable, or
could it be any session variable, at various different places in your code?

--
Adam

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
New Here ,
Aug 18, 2006 Aug 18, 2006

Copy link to clipboard

Copied

LATEST
@Aegis:
I've noticed the same. Crawler errors I just ignore.

@Adam:
Error occurs at any random point in evaluating session variables. I used to think the sessions were just timing out, but then I set a one-year session timeout and it didn't change anything.

I'll give the StructKeyExists method a try, see if that helps any.

As far as the error template, you can specify a file in CF admin to run whenever an unhandled exception occurs. It essentially runs as an include in the template that threw the error. So we have ours show the user a pretty "we're sorry" screen and send us an email with the error & all the scope dumps in it. It doesn't rerun any new code (like app.cfc), it acts something like a dynamically-included file with an abort at the end of it.

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