MindscapeHQ / raygun4cfml

Raygun.io client for Cold Fusion
Other
12 stars 15 forks source link

No SQL dump? #44

Open jesdynf opened 2 years ago

jesdynf commented 2 years ago

Hello,

I'm seeing a lot of "Unknown error" dumps of category "database" that are missing the SQL body or any clue about what's gone wrong with them -- is this expected behavior? Are there any changes I need to make to pick those details up?

I'm using the 1.4.0 bindings with Lucee 5.2, and forwarding the exception object onto Raygun without any manipulation. I get all of the elements but the SQL error through, the template and the stacktrace.

Thanks!

TheRealAgentK commented 2 years ago

Any chance you could ping me an example/screenshot, ideally both of what's tracked in RG as well as what the cfcatch/exception looks like in a WriteDump()?

jesdynf commented 2 years ago

Example test:

<cftry>
<cfquery datasource=[redacted]>
    SELECT glarfx bo banana
</cfquery> 
<cfcatch type=any>
    <cfdump var="#cfcatch#">
    <cfset APPLICATION.raygun.send(cfcatch)> 
</cfcatch>
</cftry> 

RG response: Screenshot 2022-05-31 152853

Exception dump: Screenshot 2022-05-31 153118

jesdynf commented 2 years ago

The other Raygun tabs are uninteresting but I can provide them on request; the raw data notably doesn't have anything SQL-related in it.

jesdynf commented 2 years ago

Hmm. One last note -- the test is using the cfcatch (and displaying the negative behavior) but the actual production stuff is using the exception argument from onError, in case that somehow makes a difference. I thought it was the same exception object in both cases though.

TheRealAgentK commented 2 years ago

I'll have a look at your example - from the screenshot though - the issue with "Unknown Error" is that Lucee is emitting an empty string for Message in the cfcatch variable. In this case, what would you like to see? Should maybe - if Message is empty, but Detail having a value - Detail be populated into the Raygun Message field?

The raw JSON data would be interesting too (if you don't mind posting it). If you'd rather share it privately, let me know - I'm on the CFML slack for instance.

jesdynf commented 2 years ago

That particular string is actually unimportant to me, what I need is that SQL return message under Detail because otherwise I don't have the foggiest idea what SQL is complaining about, I just know something went wrong.

jesdynf commented 1 year ago

A quick patch at the bottom of RaygunExceptionMethod solved it for our particular version of Lucee -- no idea if this is generally correct for all CF servers so I'm not submitting a PR.

// new code
            if (entryPoint.type == 'database') {
                if (!len(returnContent["message"])) returnContent["message"] = entryPoint.detail;
                if (Find("You have an error in your SQL syntax", returnContent["message"])) returnContent["message"] = "SQL syntax error";
                returnContent["data"] = { Error=entryPoint.Detail, Query=entryPoint.Sql };
            }
TheRealAgentK commented 1 year ago

Reopened

Thx for the code snippet, will look into how/if that works on ACF and then PR in.