I have defined layer with filtering. I've used operator IN because I have list of values:

  NAME "loc_mistnosti3"
  FILTER ( [ID] IN %id% )
     "id" "[0-9]"

URL address contains this list of values:


but result is still:

msCGILoadForm(): Web application error. Parameter 'id' value fails to validate.

Where is the problem?

  • Don't you need to URLEncode the commas within the list?
    – Vince
    Jun 10 '20 at 17:19
  • Because the value of id is 180,214 and your validatation pattern is [0-9]. There must be some fancy RegExp that accepts a list of numbers, separated by commas. Meanwhile you can validate anything with *.
    – user30184
    Jun 11 '20 at 0:30
  • I've tried possibly all but no success ... [0-9\,] - didn't work ... [*] - also didn't work. Answer is still msCGILoadForm(): Web application error. Parameter 'id' value fails to validate. msApplySubstitutions(): Regular expression error. Parameter pattern validation failed. or msCGILoadForm(): Web application error. Parameter 'id' value fails to validate. Jun 11 '20 at 11:13


So. My variable called id and it is the problem!


Definition of VALIDATION in LAYER looked like this:

   "id" "[0-9]"

So I have looked into mapservutil.c and there is this:

    if(strcasecmp(mapserv->request->ParamNames[i],"id") == 0) {
     if(msEvalRegex(IDPATTERN, mapserv->request->ParamValues[i]) == MS_FALSE) {
       msSetError(MS_WEBERR, "Parameter 'id' value fails to validate.", 
       return MS_FAILURE;
     strlcpy(mapserv->Id, mapserv->request->ParamValues[i], IDSIZE);

It is answer which I got every time during my trying to solve my problem. And id in this code looked a bit suspiciously.

So I've changed my variable id to xid and everything is OK now!!!

My new definition is:

   "xid" "[0-9]"

... and variable in URL is (id renamed to xid):

  • So in summary, there were 2 issues regarding your original question: 1) your FILTER syntax was incorrect, and never would display your results, as I mentioned in my answer, you are missing the quotes such as FILTER ("[reg_code]" IN "%code%") and 2) you cannot use theid variable name, good catch, I've added this as a note at the bottom of mapserver.org/mapfile/validation.html
    – mapserving
    Jun 12 '20 at 11:56
  • And finally, for good karma and to help give back to the free software that you are relying on, please create a Pull Request to help improve the MapServer documentation, at github.com/mapserver/docs Thanks!
    – mapserving
    Jun 12 '20 at 12:06

I believe your FILTER syntax is incorrect. This is working for me (pay attention to the quotes in the FILTER) :

  NAME "park"
    "wms_title"    "Parks"
    "code" "[0-9]"
  FILTER ("[reg_code]" IN "%code%")

END # Layer

You can test this outside the browser, at the commandline, such as:

mapserv -nh "QUERY_STRING=map=D:\ms4w\apps\stackexchange\filter-validation-364540\filter-validation.map&mode=map&layers=all&code=12,13" > ttt.png

Here is my parks layer in QGIS:

enter image description here

And here it is live on the MS4W demo server for you to try (try changing the end of the url to "code" values such as 24,12,13,0): https://ms4w.dev/cgi-bin/mapserv.exe?map=C:\ms4w\apps\stackexchange\filter-validation-364540\filter-validation.map&mode=map&layers=all&code=12,13 (MapServer 7.6)

Hope that helps.

(by the way, I just now added this commandline trick to the MapServer docs at https://mapserver.org/mapfile/validation.html )


  • It looks simply. I've checked and updated my definition of localization layer according to your definition - no succes. If I put only one value 212 into variable id in URL so everything is OK - map is generated. If I put two values 212,213 so result is msCGILoadForm(): Web application error. Parameter 'id' value fails to validate.. It looks like some problem with separator. Jun 12 '20 at 6:13
  • I've tried crazy thing ... I've put values directly into layer definition into FILTER - here is my definition FILTER ("[ID]" IN "212,213") and it's OK - it works and map is generated with two highlighted areas! So It has to be problem with value separator during validation process. Jun 12 '20 at 6:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.