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

Coldfusion returns 500 server error for form validation errors

New Here ,
Jan 20, 2020 Jan 20, 2020

Copy link to clipboard

Copied

Hi,

I am dealing with someone else's application and it's sort of a mess.

They're using built in form validation so the server logs this:

 

Form entries are incomplete or invalid.<ul><li>Data entered in the RATE field must be a number (you entered 'dave')

 

and then returns a scary 500 server error, which doesn't really give the user any opportunity to fix their input.

 

Why won't it just output that error to the browser like every other programming language?

TOPICS
Getting started

Views

158

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 ,
Jan 21, 2020 Jan 21, 2020

Copy link to clipboard

Copied

It's possible that something more is happening than what you see and share here.

 

For instance, if the form in question has a LOT of fields on it (perhaps including hidden ones), you may instead be running into the pre-set limitation that CF imposes (since CF8) of how many form fields are allowed. Sadly, if "too many" are posted, the page does indeed "just fail" with a 500. But there will be a log entry in the CF server.log indicating that "POST parameters exceeds the maximum limit". Can you see if that may be what was happening?

 

The limit is set (since CF10) in the CF Admin "Settings" page under "Maximum number of POST request parameters". The default is only 100. If you change it, you may need to restart CF for that to take effect (the page does not warn of that, but I'm saying you should try that if a change seems "not to help").

 

As for "how large" you should make it, there's no specific recommendation beyond "large enough for your largest forms". It was introduced to address a vulnerability that abused the freedom to upload unlimited number of form fields. If you made it 500, there would likely be no grave consequence (and assuming that was "large enough" for your needs).

 

Finally, to your wondering why there's no better handling of the error, I don't know. It's one of the few errors in CF that does this (and seems can't be caught easily by a try/catch). 

 

Let us know if this did solve the problem for you. If not, do be sure to look in all the CF logs in case there is some other explanation there for whatever error you are hitting.


/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
Community Expert ,
Jan 21, 2020 Jan 21, 2020

Copy link to clipboard

Copied

LATEST

I'll add that if what I shared is NOT the problem, you may help yourself (and help us help you) by your creating a very small demonstration page, with the least code needed to present the form, with the validation (whatever approach is being used), so show it happening. If you could then share that, we may see something you're not seeing.

 

For instance, haev you found code that's putting out the error, "Data entered in the RATE field must be a number"? If not, there were some older forms of validation (based on using cfform--though usually those DID do client-side validation), as well as a very old form of cferror called type="validation" which DID do server-side validation, but should have shown an error not just given a 500.

 

It could also be that something else in your environment (in CF or your web server) is making CF dump "just a 500 error" to the screen if a CF page gets an error. There's too much about that to share easily now. Gotta run to a call. Hope something here helps, or perhaps someone else will jump in before I can.

 

I'll note that why there was a very old cferror


/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
Resources
Documentation