@@ -198,31 +198,40 @@ impl<'a> IdList<'a> {
198198 if let Some ( id) = self . cached_type_list_id {
199199 return Ok ( Ok ( id) ) ;
200200 }
201-
201+ let field_id = self . field_id ;
202202 // Read the type list ID from container
203203 let fields = match self
204204 . txn
205- . read_selected ( self . container_id , vec ! [ self . field_id] )
205+ . read_selected ( self . container_id , vec ! [ field_id] )
206206 . await ?
207207 {
208208 Some ( f) => f,
209209 None => return Ok ( Err ( IdListError :: ContainerCellNotFound ) ) ,
210210 } ;
211-
211+ let mut create_new_type_list = async || {
212+ let result = self . create_new_type_list ( ) . await ?;
213+ if let Ok ( new_id) = result {
214+ self . cached_type_list_id = Some ( new_id) ;
215+ }
216+ Ok ( result)
217+ } ;
212218 match & fields[ 0usize ] {
213219 OwnedValue :: Id ( id) => {
214220 if id. is_unit_id ( ) && ensure_container {
215- let result = self . create_new_type_list ( ) . await ?;
216- if let Ok ( new_id) = result {
217- self . cached_type_list_id = Some ( new_id) ;
218- }
219- Ok ( result)
221+ create_new_type_list ( ) . await
220222 } else {
221223 self . cached_type_list_id = Some ( * id) ;
222224 Ok ( Ok ( * id) )
223225 }
224226 }
225- _ => Ok ( Err ( IdListError :: FormatError ) ) ,
227+ OwnedValue :: Null | OwnedValue :: NA => {
228+ trace ! ( "Creating new type list for {}" , field_id) ;
229+ create_new_type_list ( ) . await
230+ }
231+ _ => {
232+ error ! ( "Failed to get type list id, got {:?}" , fields) ;
233+ Ok ( Err ( IdListError :: FormatError ) )
234+ }
226235 }
227236 }
228237
@@ -253,9 +262,12 @@ impl<'a> IdList<'a> {
253262 ensure_container : bool ,
254263 ) -> Result < Result < Id , IdListError > , TxnError > {
255264 // Read the type list cell
256- let mut type_list_cell = match self . txn . read ( type_list_id) . await ? {
265+ let type_list_cell = match self . txn . read ( type_list_id) . await ? {
257266 Some ( cell) => cell,
258- None => return Ok ( Err ( IdListError :: FormatError ) ) ,
267+ None => {
268+ error ! ( "Failed to get type list cell, id {:?}" , type_list_id) ;
269+ return Ok ( Err ( IdListError :: FormatError ) ) ;
270+ }
259271 } ;
260272
261273 // Find existing list for this schema
@@ -264,6 +276,10 @@ impl<'a> IdList<'a> {
264276 return Ok ( Ok ( list_id) ) ;
265277 }
266278 } else {
279+ error ! (
280+ "Failed to get type list, index {:?} got {:?}" ,
281+ * ID_TYPES_MAP_ID , type_list_cell
282+ ) ;
267283 return Ok ( Err ( IdListError :: FormatError ) ) ;
268284 }
269285
@@ -312,6 +328,10 @@ impl<'a> IdList<'a> {
312328 self . txn . update ( type_list_cell) . await ?;
313329 Ok ( Ok ( list_id) )
314330 } else {
331+ error ! (
332+ "Failed to get type list, index {:?} got {:?}" ,
333+ * ID_TYPES_MAP_ID , type_list_cell
334+ ) ;
315335 Ok ( Err ( IdListError :: FormatError ) )
316336 }
317337 }
@@ -490,9 +510,11 @@ impl<'a> IdList<'a> {
490510 } ;
491511 array. remove ( index) ;
492512 } else {
513+ error ! ( "Failed to get list, index {:?} got {:?}" , * LIST_KEY_ID , map) ;
493514 return Ok ( Err ( IdListError :: FormatError ) ) ;
494515 }
495516 } else {
517+ error ! ( "Failed to get list, {:?}" , seg. data) ;
496518 return Ok ( Err ( IdListError :: FormatError ) ) ;
497519 }
498520 self . txn . update ( seg) . await . unwrap ( ) ;
0 commit comments