@@ -163,13 +163,19 @@ def composer_headers(
163163
164164 if isinstance (data , Composer ):
165165 return data .full_conversation_headers_only
166- headers = optional_raw_list (
167- data ,
168- "fullConversationHeadersOnly" ,
169- model = "Composer" ,
170- entity_id = composer_id ,
171- )
172- return headers if headers is not None else []
166+ if not isinstance (data , dict ):
167+ return []
168+ value = data .get ("fullConversationHeadersOnly" )
169+ if value is None :
170+ return []
171+ if not isinstance (value , list ):
172+ _logger .warning (
173+ "Schema drift in Composer %s: invalid type for fullConversationHeadersOnly (expected list, got %s)" ,
174+ composer_id ,
175+ type (value ).__name__ ,
176+ )
177+ return []
178+ return value
173179
174180
175181def composer_newly_created_files (data : Any , composer_id : str ) -> list [Any ]:
@@ -206,11 +212,13 @@ def bubble_relevant_files(bubble: Any, bubble_id: str = "") -> list[Any]:
206212 if isinstance (bubble , Bubble ):
207213 return bubble .relevant_files
208214 if isinstance (bubble , dict ):
209- value = bubble .get ("relevantFiles" )
210- if value is None :
211- return []
212- if isinstance (value , list ):
213- return value
215+ files = optional_raw_list (
216+ bubble ,
217+ "relevantFiles" ,
218+ model = "Bubble" ,
219+ entity_id = bubble_id ,
220+ )
221+ return files if files is not None else []
214222 return []
215223
216224
@@ -220,23 +228,27 @@ def bubble_attached_file_uris(bubble: Any, bubble_id: str = "") -> list[Any]:
220228 if isinstance (bubble , Bubble ):
221229 return bubble .attached_file_code_chunks_uris
222230 if isinstance (bubble , dict ):
223- value = bubble .get ("attachedFileCodeChunksUris" )
224- if value is None :
225- return []
226- if isinstance (value , list ):
227- return value
231+ uris = optional_raw_list (
232+ bubble ,
233+ "attachedFileCodeChunksUris" ,
234+ model = "Bubble" ,
235+ entity_id = bubble_id ,
236+ )
237+ return uris if uris is not None else []
228238 return []
229239
230240
231241def bubble_context (bubble : Any , bubble_id : str = "" ) -> dict [str , Any ]:
232242 from models .conversation import Bubble
233243
234244 if isinstance (bubble , Bubble ):
235- return bubble .context or {}
245+ return bubble .context
236246 if isinstance (bubble , dict ):
237- ctx = bubble .get ("context" )
238- if ctx is None :
239- return {}
240- if isinstance (ctx , dict ):
241- return ctx
247+ ctx = optional_raw_dict (
248+ bubble ,
249+ "context" ,
250+ model = "Bubble" ,
251+ entity_id = bubble_id ,
252+ )
253+ return ctx if ctx is not None else {}
242254 return {}
0 commit comments