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

Messages returned from the API are converted to lower case #2155

Open
norbjd opened this issue Jul 29, 2024 · 0 comments
Open

Messages returned from the API are converted to lower case #2155

norbjd opened this issue Jul 29, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@norbjd
Copy link

norbjd commented Jul 29, 2024

When unmarshaled, messages returned from Scaleway API are converted in lower case, see https://github.com/scaleway/scaleway-sdk-go/blob/v1.0.0-beta.29/scw/errors.go#L54.

In general cases, this is not a big deal, but when things like units are returned in the error message, it makes sense to keep the case. For example, when creating a container with a memory limit not in the expected range, the received error is:

scaleway-sdk-go: http error 400 Bad Request: 500 mvcpu require a minimum of 500 mib and a maximum of 2000 mib of memory.

Here, instead of returning MiB (mebibytes), we have mib (millibits?), and that can be confusing.

I've noticed this by running Terraform (which under the hood uses scaleway-sdk-go), but it should be the case for all messages converted by scaleway-sdk-go. Anyway, to reproduce with Terraform, we can use:

resource "scaleway_container_namespace" "main" {
  name = "serverless-example-ns"
  description = "Namespace managed by terraform"
}

resource "scaleway_container" "main" {
  name = "serverless-example-container"
  description = "NGINX container deployed with terraform"
  namespace_id = scaleway_container_namespace.main.id
  registry_image = "docker.io/library/nginx:latest"
  port = 80
  cpu_limit = 500
  memory_limit = 400
  min_scale = 0
  max_scale = 1
  privacy = "public"
  protocol = "http1"
  deploy = true
}

And you should see the error message above (in lower case).

I suggest to avoid the lower case conversion in scaleway-sdk-go, and return directly the message sent by the API. Maybe there is a real explanation of the conversion, so feel free to do whatever the best is.

Thanks :)

@Laure-di Laure-di added the bug Something isn't working label Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants