Skip to content

Commit 3eb230d

Browse files
committed
add handling of nil etre entity
1 parent 34b9321 commit 3eb230d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

api/api_gomux.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1332,10 +1332,14 @@ func (api *API) WriteResult(rc *req, w http.ResponseWriter, ids interface{}, err
13321332
httpStatus = http.StatusCreated
13331333
}
13341334
case etre.Entity:
1335+
var id string // default empty string
13351336
// Entity from DeleteLabel
13361337
diff := ids.(etre.Entity)
1338+
13371339
// _id from db is primitive.ObjectID, convert to string
1338-
id := diff["_id"].(primitive.ObjectID).Hex()
1340+
if diff != nil && diff["_id"] != nil {
1341+
id = diff["_id"].(primitive.ObjectID).Hex()
1342+
}
13391343
writes = []etre.Write{
13401344
{
13411345
EntityId: id,

0 commit comments

Comments
 (0)