Skip to content

Go codegen: address review feedback from #22057 - #22201

Open
David Pine (IEvangelist) wants to merge 3 commits into
mainfrom
ievangelist-review-go-child-resource-errors
Open

David Pine (IEvangelist) wants to merge 3 commits into
mainfrom
ievangelist-review-go-child-resource-errors

Conversation

@IEvangelist

Copy link
Copy Markdown
Member

Description

Follow-up to #22057 (already on main) addressing its review feedback:

  • FormatError now finds joined errors behind fmt.Errorf("...: %w", ...) wrappers.
  • DTO callback properties bind the registering client, so token and handle arguments decode correctly instead of using callbackArg[*CancellationToken].
  • Union parameters with handle members propagate an errored handle's Err() before sending the capability.
  • A forwarded callback CancellationToken reuses the host-issued ID, so cancelling the host token cancels the nested operation.
  • The builder's Err API summary now describes the aggregated errors.

Intentionally not done: capping CancellationTokenRegistry ID size. It requires an authenticated guest that already controls the connection.

Added Go regression tests; snapshots updated accordingly.

Test: .\dotnet.cmd test --project tests/Aspire.Hosting.CodeGeneration.Go.Tests/Aspire.Hosting.CodeGeneration.Go.Tests.csproj --no-launch-profile -- --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true" — first run failed 4 (snapshot updates), rerun after accepting snapshots: 137 passed, 0 failed.

Relates to #22057

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No

- FormatError finds joined errors behind fmt.Errorf %w wrappers
- DTO callbacks bind the registering client so tokens/handles work
- Union parameters with handle members propagate Err() before sending
- Forwarded callback tokens reuse the host-issued ID
- Builder Err API summary reflects aggregated errors

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 22201

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 22201"

@github-actions github-actions Bot added the area-integrations Issues pertaining to Aspire Integrations packages label Nov 12, 2026
@github-actions

This comment has been minimized.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved critical defects can let builds proceed after failed resource operations and cause cross-client cancellation to miss forwarded operations or target unrelated tokens.

3 open issues
What changed in this PR

This follow-up to #22057 improves error propagation and callback handling in Aspire’s generated Go SDK.

Changes:

  • Formats wrapped aggregate errors and propagates failed handle arguments in unions.
  • Binds DTO callbacks to their registering client and preserves host-issued cancellation IDs when forwarding tokens.
  • Corrects the builder’s Err() API summary and adds regression tests with updated snapshots.
File Description
tests/​Aspire.Hosting.CodeGeneration.Go.Tests/​Snapshots/​TwoPassScanningGeneratedAspire.verified.go Updates generated callback decoding and union error checks.
tests/​Aspire.Hosting.CodeGeneration.Go.Tests/​Snapshots/​GoApiExportTests.GoOnlySurface.verified.json Updates the builder’s aggregated-error summary.
tests/​Aspire.Hosting.CodeGeneration.Go.Tests/​Snapshots/​EscapedMetadataGeneratedAspire.verified.go Reflects client-bound DTO callbacks with escaped names.
tests/​Aspire.Hosting.CodeGeneration.Go.Tests/​Snapshots/​AtsGeneratedAspire.verified.go Captures generated runtime and union-check changes.
tests/​Aspire.Hosting.CodeGeneration.Go.Tests/​AtsGoCodeGeneratorTests.cs Adds error, callback-binding, and token-forwarding regressions.
src/​Aspire.Hosting.CodeGeneration.Go/​Resources/​transport.go Updates error formatting, callback binding, and token forwarding.
src/​Aspire.Hosting.CodeGeneration.Go/​AtsGoCodeGenerator.cs Emits union error checks and client-aware DTO callbacks.
src/​Aspire.Hosting.CodeGeneration.Go/​AtsGoCodeGenerator.ApiProjection.cs Corrects the exported builder Err() documentation.

Review effort: Balanced

…leReference in unions

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

Tests selector

4 / 101 PR test projects · 4 PR jobs, from 8 changed files.

Selected PR test projects (4 / 101)

Aspire.Cli.EndToEnd.Tests, Aspire.Cli.Tests, Aspire.Hosting.CodeGeneration.Go.Tests, Aspire.Hosting.RemoteHost.Tests

Selected PR jobs (4)

cli-starter-validation, extension-e2e, polyglot, typescript-api-compat


How these were chosen — grouped by what changed

🔧 src/Aspire.Hosting.CodeGeneration.Go/AtsGoCodeGenerator.ApiProjection.cs (changed source)
→ 1 directly: Aspire.Hosting.CodeGeneration.Go.Tests
→ 1 via the project graph: Aspire.Hosting.RemoteHost.Tests

🔧 src/Aspire.Hosting.CodeGeneration.Go/AtsGoCodeGenerator.cs (changed source)
→ 2 directly: Aspire.Cli.Tests, Aspire.Hosting.CodeGeneration.Go.Tests

📦 affected project Aspire.Hosting.CodeGeneration.Go
→ 1 test: Aspire.Cli.EndToEnd.Tests

🔧 src/Aspire.Hosting.CodeGeneration.Go/Resources/transport.go (changed source)
→ 1 directly: Aspire.Hosting.CodeGeneration.Go.Tests

🧪 tests/Aspire.Hosting.CodeGeneration.Go.Tests/AtsGoCodeGeneratorTests.cs (changed test)
→ 1 directly: Aspire.Hosting.CodeGeneration.Go.Tests

🧪 tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/AtsGeneratedAspire.verified.go (changed test)
→ 1 directly: Aspire.Hosting.CodeGeneration.Go.Tests

🧪 tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/EscapedMetadataGeneratedAspire.verified.go (changed test)
→ 1 directly: Aspire.Hosting.CodeGeneration.Go.Tests

🧪 tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/GoApiExportTests.GoOnlySurface.verified.json (changed test)
→ 1 directly: Aspire.Hosting.CodeGeneration.Go.Tests

🧪 tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.go (changed test)
→ 1 directly: Aspire.Hosting.CodeGeneration.Go.Tests

Job reasons

Job Triggered by
cli-starter-validation affected project Aspire.Hosting.CodeGeneration.Go
extension-e2e • src/Aspire.Hosting.CodeGeneration.Go/AtsGoCodeGenerator.ApiProjection.cs, src/Aspire.Hosting.CodeGeneration.Go/AtsGoCodeGenerator.cs, src/Aspire.Hosting.CodeGeneration.Go/Resources/transport.go
• affected project Aspire.Hosting.CodeGeneration.Go
polyglot affected project Aspire.Hosting.CodeGeneration.Go
typescript-api-compat affected project Aspire.Hosting.CodeGeneration.Go

Selection computed for commit c65cc0c.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the Go SDK error-propagation and callback-handling changes.

No open issues 🎉

3 resolved since last review

Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-integrations Issues pertaining to Aspire Integrations packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants