Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return Error or Warning Message #96

Closed
Jnb2387 opened this issue Dec 29, 2021 · 7 comments
Closed

Return Error or Warning Message #96

Jnb2387 opened this issue Dec 29, 2021 · 7 comments
Labels
enhancement New feature or request

Comments

@Jnb2387
Copy link

Jnb2387 commented Dec 29, 2021

I am able to view the ERROR code from my plpgsql function on the server, but is it possible to return the message from postgres in the response? I am not sure if this was returned before #59 , the response empty data array is useful but even with a raise exception its hard to know the query didnt run successfully.

@dr-jts
Copy link
Collaborator

dr-jts commented Dec 29, 2021

My thinking was that it is better to not return the internal errors via the API, since that might leak unwanted information. They should be logged, however. Are you not seeing this?

@dr-jts dr-jts added design Design suggestion enhancement New feature or request and removed design Design suggestion labels Dec 29, 2021
@Jnb2387
Copy link
Author

Jnb2387 commented Dec 29, 2021

I see them logged on the server, I may just be forcing it to work but I was trying to test out and create an update or rather upsert function and send the parameters via pg_featureserv, which does work fine but if I create an exception in the function it still will return with a 200 OK response. This may be fine as the data array returned will still be empty and I can error out on that.

@dr-jts
Copy link
Collaborator

dr-jts commented Dec 29, 2021

Right, I just noticed that myself. That does seem like a design flaw. The error should be indicated in the response somehow, even if it doesn't contain the internal error message. I will have to check and see if there is a standard way to encode an error message in the response document.

At least the HTTP response code should be set to indicate an error. Perhaps 500, or else 404?

@dr-jts
Copy link
Collaborator

dr-jts commented Dec 30, 2021

It turns out that this is in fact a bug. This particular error was not being passed back up the function chain. This is now fixed in da64e20.

I'm not sure the reponse body is appropriate, however - it is HTML, rather than JSON. This needs looking into. The HTTP Status Code is correct however - it is 500.

@dr-jts
Copy link
Collaborator

dr-jts commented Feb 9, 2022

@Jnb2387 can this issue be closed?

@Jnb2387
Copy link
Author

Jnb2387 commented Feb 9, 2022

Yes sorry. PG_Featureserv just keeps getting better and better! Thanks @dr-jts

@Jnb2387 Jnb2387 closed this as completed Feb 9, 2022
@dr-jts
Copy link
Collaborator

dr-jts commented Feb 10, 2022

PG_Featureserv just keeps getting better and better! Thanks @dr-jts

Great to hear. Stay tuned for a release coming soon, with all the new features that have been piling up. And hopefully some support for CQL!

crunchyheath pushed a commit to crunchyheath/pg_featureserv that referenced this issue Jan 11, 2024
* add basic metrics
* add go.sum (`make build` requires it up to date)
* only track metrics for valid layers
* add 404 and 400 errors
* 404 for layer not found errors
* 400 for invalid tile errors (same behavior as OSM)
* metrics ignore all 4xx errors
* don't try to record metrics if label error occurs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants