@@ -171,10 +171,10 @@ func logWithSpanContext(span tracer.Span) zerolog.Logger {
171171
172172/*
173173*
174- This function is to typecast entity values unmarshalled from JSON to the actual entity type specified in the entity definition .
175- This is because of a bug when using an entity defined with ValueType_INT32
174+ This function fixes the bug when the entity join key type is INT32 .
175+ It typecasts the entity values to int32, as unmarshalled JSON values only return int64.
176176*/
177- func typecastToEntityIntType (val * repeatedValue , entityType prototypes.ValueType_Enum ) {
177+ func typecastToInt32Type (val * repeatedValue , entityType prototypes.ValueType_Enum ) {
178178 if val .int64Val != nil {
179179 if entityType == prototypes .ValueType_INT32 {
180180 for _ , v := range val .int64Val {
@@ -183,14 +183,6 @@ func typecastToEntityIntType(val *repeatedValue, entityType prototypes.ValueType
183183 val .int64Val = nil
184184 }
185185 }
186- if val .int32Val != nil {
187- if entityType == prototypes .ValueType_INT64 {
188- for _ , v := range val .int32Val {
189- val .int64Val = append (val .int64Val , int64 (v ))
190- }
191- val .int32Val = nil
192- }
193- }
194186}
195187
196188func (s * httpServer ) getOnlineFeatures (w http.ResponseWriter , r * http.Request ) {
@@ -238,11 +230,15 @@ func (s *httpServer) getOnlineFeatures(w http.ResponseWriter, r *http.Request) {
238230 }
239231 entitiesProto := make (map [string ]* prototypes.RepeatedValue )
240232 for key , value := range request .Entities {
241- var entity , err = s .fs .ListEntity (key )
233+ var entity , err = s .fs .ListEntityByJoinKey (key )
242234 if err != nil {
243-
235+ logSpanContext .Error ().Err (err ).Msg ("Error getting entity from registry" )
236+ writeJSONError (w , fmt .Errorf ("Error getting entity from registry: %+v" , err ), http .StatusInternalServerError )
237+ return
238+ }
239+ if value .int64Val != nil {
240+ typecastToInt32Type (& value , entity .Dtype )
244241 }
245- typecastToEntityIntType (& value , entity .Dtype )
246242 entitiesProto [key ] = value .ToProto ()
247243 }
248244 requestContextProto := make (map [string ]* prototypes.RepeatedValue )
0 commit comments