Open-EO / openeo-aggregator

openEO driver that combines multiple other drivers
https://open-eo.github.io/openeo-aggregator/
Apache License 2.0
1 stars 1 forks source link

Better handling of "insufficient credits" error #121

Closed soxofaan closed 4 months ago

soxofaan commented 1 year ago

reported by @clausmichele when he hit the credits limit:

OpenEoApiError: [500] Internal: Server error: OpenEoApiError('[402] unknown: You do not have sufficient credits to perform this request. Please visit https://portal.terrascope.be/pages/pricing to find more information on how to buy additional credits.') (ref: r-7b93767ec8ee47b5a1c69feaf2512687)

The user get a [500] Internal: Server error from the aggregator, but this is actually a client error (see the inner 402 code). The aggregator should not change this to a 5xx code

soxofaan commented 6 months ago

I just tried to trigger the "insufficient credits" problem with a test account, but there seems to be an issue so that the error is not raised. So at the moment I can not reproduce it

soxofaan commented 6 months ago

Issue is resolved now, and the insufficient credits error still has this (non-compliant) format (missing "code" field):

HTTP status 402 body {"message":"You do not have sufficient credits to perform this request. Please visit https://portal.terrascope.be/pages/pricing to find more information on how to buy additional credits."}

Ideally a "code" field is added there but we can start with handling status 402 Payment Required

JanssenBrm commented 6 months ago

Unless I'm mistaken, this needs to be fixed in the plugin that executes the credit check. From the accounting perspective, we only send execution: false as a 200 OK response.

soxofaan commented 6 months ago

indeed, that's what I made https://github.com/eu-cdse/openeo-cdse-infra/issues/124 for

soxofaan commented 6 months ago

I decided to just pass through the original (openEO compliant) errors from upstream (on sync and batch processing), instead of wrapping everything automatically in a generic "500 Internal error"

Final part to fix the original issue here is to actually have openEO compliant error payload on "insufficient credits" event -> https://github.com/eu-cdse/openeo-cdse-infra/issues/124

JeroenVerstraelen commented 4 months ago

@soxofaan is this still blocked?

soxofaan commented 4 months ago

The aggregator part was not really blocked, I was just waiting for https://github.com/eu-cdse/openeo-cdse-infra/issues/124 to finally close this ticket, which can be done now indeed