From 64df82aa9cd973228037e849a03984479fb0b2ec Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 7 Jan 2026 21:41:06 +0000 Subject: [PATCH 1/6] Initial plan From d94d55b58c37720f3a625261e1d02cba9f630beb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 7 Jan 2026 21:47:33 +0000 Subject: [PATCH 2/6] Fix nil pointer dereference in executeAzdCommand Co-authored-by: trangevi <26490000+trangevi@users.noreply.github.com> --- .../testUtilities/test_utils.go | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/cli/azd/extensions/azure.ai.agents/test/integrationTests/testUtilities/test_utils.go b/cli/azd/extensions/azure.ai.agents/test/integrationTests/testUtilities/test_utils.go index d813f6fff00..692658c9ceb 100644 --- a/cli/azd/extensions/azure.ai.agents/test/integrationTests/testUtilities/test_utils.go +++ b/cli/azd/extensions/azure.ai.agents/test/integrationTests/testUtilities/test_utils.go @@ -185,11 +185,27 @@ func executeAzdCommand(ctx context.Context, cli *azdcli.CLI, testSuite *Integrat cli.WorkingDirectory = testSuite.AzdProjectDir result, err := cli.RunCommandWithStdIn(ctx, "", args...) - output := result.Stdout + result.Stderr + + var output string + if result != nil { + output = result.Stdout + result.Stderr + } LogCommandOutput(strings.Join(args, " "), []byte(output)) - if err != nil || result.ExitCode != 0 { + if err != nil { + var exitCode int + if result != nil { + exitCode = result.ExitCode + } + Logf("Command failed with error: %v, exit code: %d", err, exitCode) + return "", &InitError{ + Message: output, + Err: fmt.Errorf("exit code %d: %w", exitCode, err), + } + } + + if result.ExitCode != 0 { Logf("Command failed with error: %v, exit code: %d", err, result.ExitCode) return "", &InitError{ Message: output, From f538d2887b5550b8d7a13e6920cb320ec56bd427 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 7 Jan 2026 21:49:20 +0000 Subject: [PATCH 3/6] Fix error handling in non-error exit code case Co-authored-by: trangevi <26490000+trangevi@users.noreply.github.com> --- .../test/integrationTests/testUtilities/test_utils.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/azd/extensions/azure.ai.agents/test/integrationTests/testUtilities/test_utils.go b/cli/azd/extensions/azure.ai.agents/test/integrationTests/testUtilities/test_utils.go index 692658c9ceb..08659a18b0b 100644 --- a/cli/azd/extensions/azure.ai.agents/test/integrationTests/testUtilities/test_utils.go +++ b/cli/azd/extensions/azure.ai.agents/test/integrationTests/testUtilities/test_utils.go @@ -206,10 +206,10 @@ func executeAzdCommand(ctx context.Context, cli *azdcli.CLI, testSuite *Integrat } if result.ExitCode != 0 { - Logf("Command failed with error: %v, exit code: %d", err, result.ExitCode) + Logf("Command failed with exit code: %d", result.ExitCode) return "", &InitError{ Message: output, - Err: fmt.Errorf("exit code %d: %w", result.ExitCode, err), + Err: fmt.Errorf("exit code %d", result.ExitCode), } } Logf("Command completed successfully") From d83965e1e69e0b4f179c4fb21c7b41dcf5591a6d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 7 Jan 2026 21:50:49 +0000 Subject: [PATCH 4/6] Add defensive nil check for result in exit code check Co-authored-by: trangevi <26490000+trangevi@users.noreply.github.com> --- .../test/integrationTests/testUtilities/test_utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/azd/extensions/azure.ai.agents/test/integrationTests/testUtilities/test_utils.go b/cli/azd/extensions/azure.ai.agents/test/integrationTests/testUtilities/test_utils.go index 08659a18b0b..6fef5191ebd 100644 --- a/cli/azd/extensions/azure.ai.agents/test/integrationTests/testUtilities/test_utils.go +++ b/cli/azd/extensions/azure.ai.agents/test/integrationTests/testUtilities/test_utils.go @@ -205,7 +205,7 @@ func executeAzdCommand(ctx context.Context, cli *azdcli.CLI, testSuite *Integrat } } - if result.ExitCode != 0 { + if result != nil && result.ExitCode != 0 { Logf("Command failed with exit code: %d", result.ExitCode) return "", &InitError{ Message: output, From 08c794183c6b3051626385a410e1474491a8c630 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 7 Jan 2026 21:52:14 +0000 Subject: [PATCH 5/6] Improve error handling with -1 exit code and clarifying comments Co-authored-by: trangevi <26490000+trangevi@users.noreply.github.com> --- .../test/integrationTests/testUtilities/test_utils.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cli/azd/extensions/azure.ai.agents/test/integrationTests/testUtilities/test_utils.go b/cli/azd/extensions/azure.ai.agents/test/integrationTests/testUtilities/test_utils.go index 6fef5191ebd..91bd5ce2523 100644 --- a/cli/azd/extensions/azure.ai.agents/test/integrationTests/testUtilities/test_utils.go +++ b/cli/azd/extensions/azure.ai.agents/test/integrationTests/testUtilities/test_utils.go @@ -194,7 +194,7 @@ func executeAzdCommand(ctx context.Context, cli *azdcli.CLI, testSuite *Integrat LogCommandOutput(strings.Join(args, " "), []byte(output)) if err != nil { - var exitCode int + var exitCode int = -1 // Default to -1 when result is nil (command failed to start) if result != nil { exitCode = result.ExitCode } @@ -205,6 +205,9 @@ func executeAzdCommand(ctx context.Context, cli *azdcli.CLI, testSuite *Integrat } } + // Defensive check: handle case where err is nil but exit code is non-zero + // This shouldn't normally happen based on RunCommandWithStdIn implementation, + // but we check defensively in case the implementation changes if result != nil && result.ExitCode != 0 { Logf("Command failed with exit code: %d", result.ExitCode) return "", &InitError{ From 22aad2c6bfcef0dafdfc0a3e7ff965e7620eac6d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 7 Jan 2026 21:53:27 +0000 Subject: [PATCH 6/6] Fix incorrect function documentation comment Co-authored-by: trangevi <26490000+trangevi@users.noreply.github.com> --- .../test/integrationTests/testUtilities/test_utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/azd/extensions/azure.ai.agents/test/integrationTests/testUtilities/test_utils.go b/cli/azd/extensions/azure.ai.agents/test/integrationTests/testUtilities/test_utils.go index 91bd5ce2523..e09998ad13a 100644 --- a/cli/azd/extensions/azure.ai.agents/test/integrationTests/testUtilities/test_utils.go +++ b/cli/azd/extensions/azure.ai.agents/test/integrationTests/testUtilities/test_utils.go @@ -220,7 +220,7 @@ func executeAzdCommand(ctx context.Context, cli *azdcli.CLI, testSuite *Integrat return output, nil } -// executeAzdCommand executes an azd command and returns output and agent version if available +// executeAzdCommandWithExec executes an azd command using exec.Command and returns the output func executeAzdCommandWithExec(ctx context.Context, testSuite *IntegrationTestSuite, timeout time.Duration, args []string) (string, error) { ctx, cancel := context.WithTimeout(ctx, timeout) defer cancel()