Skip to content

Commit 4199b7a

Browse files
authored
[Fix] Reading model serving endpoint with no config (#4603)
## Changes <!-- Summary of your changes that are easy to understand --> Importing model serving with empty config should not throw `Error: cannot read model serving: panic: runtime error: invalid memory address or nil pointer dereference` ## Tests <!-- How is this tested? Please see the checklist below and also describe any other relevant tests --> - [x] `make test` run locally - [x] covered with integration tests in `internal/acceptance` - [x] using Go SDK NO_CHANGELOG=true
1 parent 44d2830 commit 4199b7a

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

serving/resource_model_serving.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ func ResourceModelServing() common.Resource {
8787
}
8888
if sOrig.Config == nil {
8989
// If it is a new resource, then we only return ServedEntities
90-
endpoint.Config.ServedModels = nil
90+
if endpoint.Config != nil {
91+
endpoint.Config.ServedModels = nil
92+
}
9193
} else {
9294
// If it is an existing resource, then have to set one of the responses to nil
9395
if sOrig.Config.ServedModels == nil {

serving/resource_model_serving_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,37 @@ func TestModelServingRead(t *testing.T) {
444444
}.ApplyNoError(t)
445445
}
446446

447+
func TestModelServingReadEmptyConfig(t *testing.T) {
448+
qa.ResourceFixture{
449+
Fixtures: []qa.HTTPFixture{
450+
{
451+
Method: http.MethodGet,
452+
Resource: "/api/2.0/serving-endpoints/test-endpoint?",
453+
Response: map[string]any{
454+
"creation_timestamp": 1743085336000,
455+
"creator": "b76b6808-9e10-43b3-be20-6b6d19ed1af0",
456+
"creator_display_name": "DECO-TF-AWS-PROD-IS-SPN",
457+
"creator_kind": "ServicePrincipal",
458+
"id": "84f4b90597b94fb1846a96cb505772f1",
459+
"last_updated_timestamp": 1743085336000,
460+
"name": "test-endpoint-462f54a7-fefd-4d48-bdc2-2659a5439d94",
461+
"permission_level": "CAN_MANAGE",
462+
"resource_credential_strategy": "EMBEDDED_CREDENTIALS",
463+
"route_optimized": false,
464+
"state": map[string]any{
465+
"config_update": "NOT_UPDATING",
466+
"ready": "NOT_READY",
467+
"suspend": "NOT_SUSPENDED",
468+
},
469+
},
470+
},
471+
},
472+
Resource: ResourceModelServing(),
473+
Read: true,
474+
ID: "test-endpoint",
475+
}.ApplyNoError(t)
476+
}
477+
447478
func TestModelServingRead_Error(t *testing.T) {
448479
qa.ResourceFixture{
449480
Fixtures: []qa.HTTPFixture{

0 commit comments

Comments
 (0)