cloudfoundry / cloud_controller_ng

Cloud Foundry Cloud Controller
Apache License 2.0
191 stars 357 forks source link

How to know CF CAPI errors from specific endpoints? #3180

Closed IvanShastakouSAP closed 5 months ago

IvanShastakouSAP commented 1 year ago

Hello colleugues, currently I am working on contribution to cf-java-client (https://github.com/cloudfoundry/cf-java-client) The essence of contrubution is to migrate client implementation from v2 CF APIs to v3.

Issue

How to know Cloud Foundry CAPI errors (in V3 APIs) from specific endpoints?

Context

I looked through CF API V3 documentation: https://v3-apidocs.cloudfoundry.org/version/3.131.0/index.html#error](https://v3-apidocs.cloudfoundry.org/version/3.131.0/index.html#errors

And I did not find any inforamtion about possible returned errors from specific APIs. To contribute into cf-java-client we want to provide good and correct error handling. But we don't have an information about possible errors from endpoint.

For now, we need to know the possible return errors from these endpoints:

  1. GET /v3/processes/:guid/stats (https://v3-apidocs.cloudfoundry.org/version/3.131.0/index.html#get-stats-for-a-process)
  2. GET /v3/processes/:guid (https://v3-apidocs.cloudfoundry.org/version/3.131.0/index.html#get-a-process)
  3. GET /v3/apps/:guid/routes (https://v3-apidocs.cloudfoundry.org/version/3.131.0/index.html#list-routes-for-an-app)
  4. GET /v3/apps/:guid/droplets/current (https://v3-apidocs.cloudfoundry.org/version/3.131.0/index.html#get-current-droplet)
  5. GET /v3/processes/:guid/sidecars (https://v3-apidocs.cloudfoundry.org/version/3.131.0/index.html#list-sidecars-for-process)

We also did some research and found all defined errors there: https://github.com/cloudfoundry/cloud_controller_ng/tree/935f91063e2afa91109d57a44242ad4638885e3a/errors

But it is impossible to handle absolutely everything due to their number, so we would like only those that can be returned when the endpoints described above are called.

Also, could you explain about file naming of these errors, just for example v2.yaml and v3.yaml. v3.yaml errors is used only in API V3 or v2.yaml errors also can be used in V3 API?

Thanks!

moleske commented 1 year ago

I think if you handle the common errors as defined in the docs you linked you will catch what is needed. Looking through the various errors yml files, there are only a few places where we have an error not covered by common errors (which makes sense, they are not common). An example of one not in common errors is 409, but that is only services related, which is none of the endpoints you listed.

As far as naming of the errors, I'm not sure of the history there. Looking at the history, I believe v3.yml are only in the v3 api, while v2.yml can be in the v2 or v3 api. But if I understand what the cf-java-client needs, you just need to handle the common errors as previously mentioned (400, 401, 403, 404, 422, 500)