2727_logger = logging .getLogger (__name__ )
2828
2929
30+ def _filter_str_list_elements (
31+ value : list [Any ],
32+ * ,
33+ model : str ,
34+ record_id : str ,
35+ field : str ,
36+ ) -> list [str ]:
37+ filtered : list [str ] = []
38+ for item in value :
39+ if isinstance (item , str ):
40+ filtered .append (item )
41+ else :
42+ _logger .warning (
43+ "Schema drift in %s %s: invalid %s element (expected str, got %s)" ,
44+ model ,
45+ record_id ,
46+ field ,
47+ type (item ).__name__ ,
48+ )
49+ return filtered
50+
51+
52+ def _filter_dict_list_elements (
53+ value : list [Any ],
54+ * ,
55+ model : str ,
56+ record_id : str ,
57+ field : str ,
58+ ) -> list [FileUriDict ]:
59+ filtered : list [FileUriDict ] = []
60+ for item in value :
61+ if isinstance (item , dict ):
62+ filtered .append (cast (FileUriDict , item ))
63+ else :
64+ _logger .warning (
65+ "Schema drift in %s %s: invalid %s element (expected dict, got %s)" ,
66+ model ,
67+ record_id ,
68+ field ,
69+ type (item ).__name__ ,
70+ )
71+ return filtered
72+
73+
3074@dataclass (frozen = True )
3175class Composer :
3276 """Cursor conversation row from globalStorage cursorDiskKV; requires fullConversationHeadersOnly + createdAt."""
@@ -287,7 +331,12 @@ def relevant_files(self) -> list[str]:
287331 type (value ).__name__ ,
288332 )
289333 return []
290- return cast (list [str ], value )
334+ return _filter_str_list_elements (
335+ value ,
336+ model = "Bubble" ,
337+ record_id = self .bubble_id ,
338+ field = "relevantFiles" ,
339+ )
291340
292341 @property
293342 def attached_file_code_chunks_uris (self ) -> list [FileUriDict ]:
@@ -301,7 +350,12 @@ def attached_file_code_chunks_uris(self) -> list[FileUriDict]:
301350 type (value ).__name__ ,
302351 )
303352 return []
304- return cast (list [FileUriDict ], value )
353+ return _filter_dict_list_elements (
354+ value ,
355+ model = "Bubble" ,
356+ record_id = self .bubble_id ,
357+ field = "attachedFileCodeChunksUris" ,
358+ )
305359
306360 @property
307361 def context (self ) -> BubbleContextDict :
0 commit comments