feat(mexp): Onboarding Modelexperiments - #1547
Conversation
|
This PR was marked as stale after 7 days of inactivity and will be closed after another 7 days of further inactivity. If this PR should be kept open, just add a comment, remove the stale label or push new commits to it. |
|
After those comments are resolved I will start to run the acceptance tests and manual testing |
| if instance.Id == "" { | ||
| return fmt.Errorf("instance id not present") | ||
| } |
There was a problem hiding this comment.
check if instance == nil is missing. Potential nil pointer exception
There was a problem hiding this comment.
something like this
| if instance.Id == "" { | |
| return fmt.Errorf("instance id not present") | |
| } | |
| if instance == nil || instance.Id == "" { | |
| return fmt.Errorf("instance or instance id not present") | |
| } |
| return fmt.Errorf("model input is nil") | ||
| } | ||
|
|
||
| if token.Id == "" { |
There was a problem hiding this comment.
nil check for token is missing
There was a problem hiding this comment.
same here, nil check is still missing
| return fmt.Errorf("model input is nil") | ||
| } | ||
|
|
||
| if token.Id == "" { |
There was a problem hiding this comment.
potential nil pointer on token
|
This PR was marked as stale after 7 days of inactivity and will be closed after another 7 days of further inactivity. If this PR should be kept open, just add a comment, remove the stale label or push new commits to it. |
|
@paul-sffrth I reopened some of my comments from the previous review because they are still not fixed. The nil check should be part of the mapFields function. If you have any questions, feel free to reach out |
|
I think checking on nil in the map functions don't make sense in that case, since the Instance or Token struct cannot be nil in the response struct returned by the SDK (e.g. the CreateInstanceResponse struct). The API request returns a pointer to the response struct and if the response struct is not nil then the Instance or Token object that gets mapped in the map function cannot be nil. If the response struct is nil, then the nil pointer dereference would already happen when calling the map function (for example here). Therefore I decided to check for nil before calling the map function (for example here) |
|
Checking if the passed pointer attributes are not nil should be checked in my opinion every time, independent of whether it's checked before calling the function. Someone else could use the function in the future somewhere else, and then it's possible to get a panic because there it's possible to pass a nil pointer. In our contribution guide we have also nil checks in the mapFields function, so it's the way to go in our provider: terraform-provider-stackit/.github/docs/contribution-guide/resource.go Lines 394 to 403 in f5ad219 |
7852d28 to
602c3b2
Compare
Description
This is the onboarding PR for integration STACKIT Modelexperiments into the STACKIT Terraform Provider.
It adds for customer the ability to:
Checklist
make fmtexamples/directory)make generate-docs(will be checked by CI)make test(will be checked by CI)make lint(will be checked by CI)