@@ -177,3 +177,111 @@ func TestConvertGeminiEntriesRichFormatting(t *testing.T) {
177177 t .Errorf ("ToolName() = %q, want %q" , entries [0 ].ToolName (), "Read" )
178178 }
179179}
180+
181+ func TestConvertCodexEntriesNilToolInput (t * testing.T ) {
182+ // Verify that nil ToolInput doesn't cause panic
183+ codexEntries := []codex.TranscriptEntry {
184+ {
185+ Type : "tool" ,
186+ Content : "[tool: shell_command]" ,
187+ ToolName : "shell_command" ,
188+ ToolInput : nil , // nil input (can happen with malformed JSON)
189+ },
190+ }
191+
192+ // Should not panic
193+ entries := convertCodexEntries (codexEntries )
194+
195+ if len (entries ) != 1 {
196+ t .Fatalf ("len(entries) = %d, want 1" , len (entries ))
197+ }
198+
199+ // Should still normalize tool name
200+ if entries [0 ].ToolName () != "Bash" {
201+ t .Errorf ("ToolName() = %q, want %q" , entries [0 ].ToolName (), "Bash" )
202+ }
203+
204+ // ToolInput should be empty map, not nil
205+ toolInput := entries [0 ].ToolInput ()
206+ if toolInput == nil {
207+ t .Error ("ToolInput() = nil, want empty map" )
208+ }
209+ }
210+
211+ func TestConvertCodexEntriesEmptyToolInput (t * testing.T ) {
212+ // Verify that empty ToolInput works correctly
213+ codexEntries := []codex.TranscriptEntry {
214+ {
215+ Type : "tool" ,
216+ Content : "[tool: read_file]" ,
217+ ToolName : "read_file" ,
218+ ToolInput : map [string ]interface {}{}, // empty map
219+ },
220+ }
221+
222+ // Should not panic
223+ entries := convertCodexEntries (codexEntries )
224+
225+ if len (entries ) != 1 {
226+ t .Fatalf ("len(entries) = %d, want 1" , len (entries ))
227+ }
228+
229+ // Should still normalize tool name
230+ if entries [0 ].ToolName () != "Read" {
231+ t .Errorf ("ToolName() = %q, want %q" , entries [0 ].ToolName (), "Read" )
232+ }
233+ }
234+
235+ func TestConvertGeminiEntriesNilToolInput (t * testing.T ) {
236+ // Verify that nil ToolInput doesn't cause panic
237+ geminiEntries := []gemini.TranscriptEntry {
238+ {
239+ Type : "tool" ,
240+ Content : "[tool: shell]" ,
241+ ToolName : "shell" ,
242+ ToolInput : nil , // nil input (can happen with malformed JSON)
243+ },
244+ }
245+
246+ // Should not panic
247+ entries := convertGeminiEntries (geminiEntries )
248+
249+ if len (entries ) != 1 {
250+ t .Fatalf ("len(entries) = %d, want 1" , len (entries ))
251+ }
252+
253+ // Should still normalize tool name
254+ if entries [0 ].ToolName () != "Bash" {
255+ t .Errorf ("ToolName() = %q, want %q" , entries [0 ].ToolName (), "Bash" )
256+ }
257+
258+ // ToolInput should be empty map, not nil
259+ toolInput := entries [0 ].ToolInput ()
260+ if toolInput == nil {
261+ t .Error ("ToolInput() = nil, want empty map" )
262+ }
263+ }
264+
265+ func TestConvertGeminiEntriesEmptyToolInput (t * testing.T ) {
266+ // Verify that empty ToolInput works correctly
267+ geminiEntries := []gemini.TranscriptEntry {
268+ {
269+ Type : "tool" ,
270+ Content : "[tool: read_file]" ,
271+ ToolName : "read_file" ,
272+ ToolInput : map [string ]interface {}{}, // empty map
273+ },
274+ }
275+
276+ // Should not panic
277+ entries := convertGeminiEntries (geminiEntries )
278+
279+ if len (entries ) != 1 {
280+ t .Fatalf ("len(entries) = %d, want 1" , len (entries ))
281+ }
282+
283+ // Should still normalize tool name
284+ if entries [0 ].ToolName () != "Read" {
285+ t .Errorf ("ToolName() = %q, want %q" , entries [0 ].ToolName (), "Read" )
286+ }
287+ }
0 commit comments