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

Inconsistant error on Delete #429

Closed
jtherin opened this issue Jun 2, 2020 · 0 comments · Fixed by #432
Closed

Inconsistant error on Delete #429

jtherin opened this issue Jun 2, 2020 · 0 comments · Fixed by #432
Labels
instance Instance issues, bugs and feature requests

Comments

@jtherin
Copy link
Member

jtherin commented Jun 2, 2020

When not found, some resources returns a *scw.ResourceNotFoundError and some others a *scw.ResponseError with StatusCode 404.

Using branch master (df9902c) with go 1.13.5.

To reproduce:


import (
	"fmt"
	"reflect"

	"github.com/scaleway/scaleway-sdk-go/api/instance/v1"
	"github.com/scaleway/scaleway-sdk-go/scw"
)

func main() {

	client, err := scw.NewClient(
		scw.WithDefaultOrganizationID("ORGANISATION_ID"),
		scw.WithAuth("ACCESS_KEY", "SECRET_KEY"),
	)
	if err != nil {
		panic(err)
	}

	instanceApi := instance.NewAPI(client)

	err = instanceApi.DeleteServer(&instance.DeleteServerRequest{
		ServerID: "5e858181-e9c2-4f46-8f03-0197b6eb045a",
		Zone: scw.ZoneFrPar1,
	})
	if err != nil {
		fmt.Printf("[delete instance] type: %s, value: %+v\n", reflect.TypeOf(err), err)
	}

	err = instanceApi.DeleteSecurityGroup(&instance.DeleteSecurityGroupRequest{
		SecurityGroupID: "c7b2072b-f7b5-4ae0-84b1-9c3245dbabd2",
		Zone: scw.ZoneFrPar1,
	})
	if err != nil {
		fmt.Printf("[delete sg] type: %s, value: %+v\n", reflect.TypeOf(err), err)
	}
}

Result:

[delete instance] type: *scw.ResourceNotFoundError, value: scaleway-sdk-go: resource  with ID 5e858181-e9c2-4f46-8f03-0197b6eb045a is not found
[delete sg] type: *scw.ResponseError, value: scaleway-sdk-go: http error 404 Not Found: security group "c7b2072b-f7b5-4ae0-84b1-9c3245dbabd2" not found

Expected:

[delete instance] type: *scw.ResourceNotFoundError, value: scaleway-sdk-go: resource  with ID 5e858181-e9c2-4f46-8f03-0197b6eb045a is not found
[delete sg] type: *scw.ResourceNotFoundError, value: scaleway-sdk-go: resource  with ID c7b2072b-f7b5-4ae0-84b1-9c3245dbabd2 is not found
@remyleone remyleone linked a pull request Jun 3, 2020 that will close this issue
@Sh4d1 Sh4d1 closed this as completed in #432 Jun 5, 2020
@remyleone remyleone added the instance Instance issues, bugs and feature requests label Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
instance Instance issues, bugs and feature requests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants