nanobox-io / nanobox-adapter-libcloud

A Nanobox cloud provider adapter to integrate with multiple cloud providers
MIT License
3 stars 7 forks source link

respond to client errors with 400 range responses rather than 500 #2

Open jedgalbraith opened 6 years ago

jedgalbraith commented 6 years ago

Would it be possible to respond to errors that are a result of client/user provided data with 400 range statuses rather than 500? That way Odin can handle them differently. For example:

500:{
  "errors": [
    "Your IP (...) is not authorized to use this API key"
  ]
}

Currently that error indicates to Odin that something malfunctioned within the adapter because of the 500 status, when really it was just a user setting causing the error.

danhunsaker commented 6 years ago

Most errors are reported from Libcloud by throwing a generic LibcloudError with the message, and no other way to distinguish the cause than parsing the message itself, which varies between providers. So it's probably doable, but it might take a while to rework the system to support it properly. I'll start working on that as soon as I need a break from the Azure RM adapter, since I've already started in on that one.

jedgalbraith commented 6 years ago

Oh, that's a bummer. I was hoping there would be a more straight forward way of distinguishing the cause. I don't know if it's worth it then. With other adapters, I was able to base it on the status of the response from the provider's API.

danhunsaker commented 6 years ago

Yeah, if I was talking to them directly, I'd be able to handle things more intelligently myself, too. Still, I'm a firm believer in RESTful API design, and that means labeling user errors as what they are, so I'm still going to figure this one out.

jedgalbraith commented 6 years ago

Ok. Thanks. Good luck! :-)