SDFIdk / gsearch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Service fails with filter parameter in REST call

sweco-dkgemr opened this issue · comments

When using the filter parameter in the REST calls to the API it very often fails with a 'BAD_REQUEST' error and status code 400 giving the message ’Input invalid’. This results in a very limited result list, where sometimes addresses, cadastres or the like is left out, which we consider a critical problem/blocker using the new version of the API.
It was not a problem in the previous version where filter was only available as a parameter in some of the ressources.
Error_screen_1
Error_screen_2
Error_screen_3

We are having trouble replicating the issue.
Could you provide more information?

How often do you experience the errors?
Can you provide timestamps?

I tried to reproduce the error by using this call several times, but could not reproduce the erorr.
https://api.dataforsyningen.dk/rest/gsearch/v1.0/husnummer?token=fd44f26ab5701c01ca9f570e507fe9ab&q=r&limit=10&filter=kommunekode=%270153%27

I suspect the error only occurs when calling several services at the same time.
I reproduced the error again on our own test site and this is the timestamp for the error;

timestamp

We experience the error for approximately 1/4 of the calls

We have change the error message to return more information.
Can you try again and provide us the new error message?

Called:

https://api.dataforsyningen.dk/rest/gsearch/v1.0/husnummer?q=7&limit=15&token=7030997b12f9e91e9da29f0c6e24a845&filter=kommunekode=%270153%27

Timestamp:

Thu, 25 May 2023 10:10:51 GMT

Error Message:

org.postgresql.util.PSQLException: ERROR: syntax error at or near "kommunekode"\n Where: PL/pgSQL function api.husnummer(text,text,integer,integer) line 137 at RETURN QUERY [statement:"select (api.husnummer(:q, :where, 1, :limit)).*", arguments:{positional:{}, named:{q:7,limit:15,where:kommunekode = '0153'kommunekode = '0153'}, finder:[]}]

Called:

https://api.dataforsyningen.dk/rest/gsearch/v1.0/navngivenvej?q=7&limit=15&token=7030997b12f9e91e9da29f0c6e24a845&filter=kommunekode=%270153%27

Timestamp:

Thu, 25 May 2023 10:10:51 GMT

Error message:

org.postgresql.util.PSQLException: ERROR: syntax error at or near "ORDER"\n Where: PL/pgSQL function api.navngivenvej(text,text,integer,integer) line 113 at RETURN QUERY [statement:"select (api.navngivenvej(:q, :where, 1, :limit)).*", arguments:{positional:{}, named:{q:7,limit:15,where:}, finder:[]}]

Called:

https://api.dataforsyningen.dk/rest/gsearch/v1.0/matrikel?q=7&limit=15&token=7030997b12f9e91e9da29f0c6e24a845&filter=kommunekode=%270153%27

Timestamp:

Thu, 25 May 2023 10:17:10 GMT

Error Message:

org.postgresql.util.PSQLException: ERROR: syntax error at or near "ORDER"\n Where: PL/pgSQL function api.matrikel(text,text,integer,integer) line 121 at RETURN QUERY [statement:"select (api.matrikel(:q, :where, 1, :limit)).*", arguments:{positional:{}, named:{q:7,limit:15,where:}, finder:[]}]

Called:

https://api.dataforsyningen.dk/rest/gsearch/v1.0/postnummer?q=7&limit=15&token=7030997b12f9e91e9da29f0c6e24a845&filter=kommunekode=%270153%27

Timestamp:

Thu, 25 May 2023 10:17:10 GMT

Error message:

org.postgresql.util.PSQLException: ERROR: syntax error at or near "kommunekode"
Where: PL/pgSQL function api.postnummer(text,text,integer,integer) line 101 at RETURN QUERY [statement:"select (api.postnummer(:q, :where, 1, :limit)).*", arguments:{positional:{}, named:{q:7,limit:15,where:kommunekode = '0153'kommunekode = '0153'}, finder:[]}]

We have pushed an update.

Can you please test again and provide feedback if it has worked or not?

I still get the same errors.

Called:
https://api.dataforsyningen.dk/rest/gsearch/v1.0/navngivenvej?q=7&limit=15&token=7030997b12f9e91e9da29f0c6e24a845&filter=kommunekode=%270153%27

Timestamp: Thu, 25 May 2023 11:16:05 GMT

Error message:
org.postgresql.util.PSQLException: ERROR: syntax error at or near "kommunekode"\n Where: PL/pgSQL function api.navngivenvej(text,text,integer,integer) line 113 at RETURN QUERY [statement:"select (api.navngivenvej(:q, :where, 1, :limit)).*", arguments:{positional:{}, named:{q:7,limit:15,where:kommunekode = '0153'kommunekode = '0153'}, finder:[]}]

Called:
https://api.dataforsyningen.dk/rest/gsearch/v1.0/matrikel?q=7&limit=15&token=7030997b12f9e91e9da29f0c6e24a845&filter=kommunekode=%270153%27

Timestamp: Thu, 25 May 2023 11:16:05 GMT

Error message:
org.postgresql.util.PSQLException: ERROR: syntax error at or near "ORDER"\n Where: PL/pgSQL function api.matrikel(text,text,integer,integer) line 121 at RETURN QUERY [statement:"select (api.matrikel(:q, :where, 1, :limit)).*", arguments:{positional:{}, named:{q:7,limit:15,where:}, finder:[]}]

For you information we are trying to find a way to replicate the unintentional behavior, so we don't need to ask you every time to check if the problem is fixed. And hopefully faster can find what is causing the behavior.

It is really no problem. I think the problem occurs when calling several ressources at the same time.

I just tried to reduce it to only calling the matrikel resource and i can make several request in a row without causing any errors.
Adding husnummer so that I request results for both matrikel and husnummer at the same time makes it fail in some instances

Could I get you to test again?
We tried increasing the resources available for Gsearch.

I'm sorry to say that it still fails in the same way.

We managed to replicate the error and identified where the issue is.
Hopefully we'll have a fix very soon.

I'm looking forward to that.

It should be fixed now. It was an issue with ogr.geotools encodeToString that shares memory between the different threads.
2eb754c

It is working in our end now also. Thanks for quick response and fix.