Skip to content

Surface extension build-script output when azd x build fails#8526

Closed
Copilot wants to merge 2 commits into
mainfrom
copilot/check-extension-build-output
Closed

Surface extension build-script output when azd x build fails#8526
Copilot wants to merge 2 commits into
mainfrom
copilot/check-extension-build-output

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 2, 2026

Extension creation/build failures were reporting a generic build error while dropping the actionable build-script output from the user-visible task summary. This made it unclear what failed and whether the extension state was recoverable.

  • Failure-path output visibility

    • Keep task-list failure text concise (Build failed...) using subprocessErrorTail(...) for a short inline hint.
    • Persist full captured CombinedOutput() on build-script failure and print it after task-list rendering under a dedicated Build output: section.
    • Avoid embedding raw multi-line subprocess output in DetailedError description (task list only renders the description field).
  • Behavior alignment with existing subprocess patterns

    • Reuse the existing subprocessErrorTail pattern already used by extension init subprocess handling, so users get a compact summary + full output details.
  • Targeted test coverage

    • Add focused tests for the new output writer to verify:
      • output is emitted when non-empty
      • no output is emitted for whitespace-only content
if result, err := cmd.CombinedOutput(); err != nil {
    buildFailureOutput = string(result)

    return ux.Error, common.NewDetailedError(
        "Build failed"+subprocessErrorTail(result),
        fmt.Errorf("failed to build artifacts: %w", err),
    )
}

// deferred after task-list completion
writeBuildFailureOutput(os.Stderr, buildFailureOutput)
Original prompt

I noticed a small bug when creating an extension. When it failed (on the build step) the output appears to be thrown away, so (from a user perspective) you don't know what broke, or what you can do to fix it.

Can you take a look and see if that's deliberate, or if it's just a bug. If it's deliberate, I think we'll want to change it since it's at a very awkward spot, and it's unclear if you can retry or if it's busted completely.

The user has attached the following file paths as relevant context:

  • .github/copilot-instructions.md
  • AGENTS.md

Created from VS Code.

Co-authored-by: richardpark-msft <51494936+richardpark-msft@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate build output handling during extension creation Surface extension build-script output when azd x build fails Jun 2, 2026
Copilot AI requested a review from richardpark-msft June 2, 2026 22:57
@richardpark-msft
Copy link
Copy Markdown
Member

@copilot Are there are other stages in the extension workflow that have this same issue?

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jun 2, 2026

@copilot Are there are other stages in the extension workflow that have this same issue?

Yes — I found at least one more in the extension workflow: azd x pack’s Building extension task (cli/azd/extensions/microsoft.azd.extensions/internal/cmd/pack.go). It puts CombinedOutput() into the wrapped error ("Command output: ..."), but TaskList renders only DetailedError.Description(), so that output is effectively dropped.

Also worth noting: init.go’s runSubprocess appends subprocessErrorTail(...) to the inner error (not the description), so the inline tail can be hidden there for the same reason.

@richardpark-msft
Copy link
Copy Markdown
Member

@copilot Elaborate on 'the tail'

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jun 2, 2026

@copilot Elaborate on 'the tail'

By “the tail” I mean the short suffix returned by subprocessErrorTail(...) (in init.go) and appended to the task description/error text.

It extracts one compact line from captured subprocess output:

  • prefers the first ERROR: / Error: line
  • otherwise uses the last non-empty line
  • strips ANSI escape codes
  • returns it as ": <message>"

So instead of dumping full multiline output, the task line becomes something like:
Build failed: failed to compile plugin

The full raw output should be printed separately (e.g., under Build output:).

@richardpark-msft richardpark-msft deleted the copilot/check-extension-build-output branch June 2, 2026 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants