Skip to content

Allow structured Kubernetes manifest field values - #21824

Merged
David Pine (IEvangelist) merged 3 commits into
mainfrom
ievangelist-structured-manifest-fields
Nov 6, 2026
Merged

David Pine (IEvangelist) merged 3 commits into
mainfrom
ievangelist-structured-manifest-fields

Conversation

@IEvangelist

@IEvangelist David Pine (IEvangelist) commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Description

Polyglot AppHosts can now author custom Kubernetes manifests with nested objects and arrays, including CiliumNetworkPolicy ingress rules and selectors whose label keys contain dots and slashes.

Remove the scalar-only AspireUnion restriction from KubernetesManifestResource.WithField. The CLR signature remains WithField(string, object) and the existing normalization/YAML paths handle the structured values. JSON numbers now use the same finite/range checks as CLR numeric values, including inside nested objects and arrays.

Dot-separated paths and last-write-wins replacement are unchanged. Supply dotted keys inside a map subtree rather than adding path escape syntax. Manifest metadata still uses dedicated APIs.

Part of #18080: addresses the remaining structured-manifest limitation (bug 2). The Go Configure callback panic and integer union handling (bug 1) were already fixed by merged #21188 and are not changed here.

User-facing usage

await api.publishAsKubernetesService(async (service) => {
    const policy = await service.addManifest("cilium.io/v2", "CiliumNetworkPolicy", "api-netpol");
    await policy.withField("spec.endpointSelector.matchLabels", {
        "app.kubernetes.io/component": "api"
    });
    await policy.withField("spec.ingress", [{
        fromEndpoints: [{
            matchLabels: { "app.kubernetes.io/component": "frontend" }
        }]
    }]);
});

C# AppHosts continue to use AdditionalResources with a BaseKubernetesResource subclass for typed custom resources; no public CLR API is added.

Generated SDK compatibility

Focused snapshots cover the real Kubernetes capability in all five generators: Go any without the scalar union guard, TypeScript any, Python typing.Any, Java Object, and Rust &Value. Java's transport still unwraps existing AspireUnion arguments, so existing source calls remain usable after regeneration. The CLR signature and capability ID are unchanged. No generator implementation, shared runtime, or release API baseline files are edited.

Validation

  • .\restore.cmd - passed; repository-wide restore reported 17 NuGet vulnerability warnings.
  • dotnet test --project tests\Aspire.Hosting.RemoteHost.Tests\Aspire.Hosting.RemoteHost.Tests.csproj --no-launch-profile -- --filter-class "*.KubernetesManifestTests" --filter-class "*.CapabilityDispatcherTests" --filter-class "*.AtsMarshallerTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true" - passed, 278 tests.
  • dotnet test --project tests\Aspire.Hosting.RemoteHost.Tests\Aspire.Hosting.RemoteHost.Tests.csproj --no-launch-profile -- --filter-class "*.KubernetesManifestTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true" - passed, 10 tests after normalizing trailing whitespace in generated snapshots.
  • dotnet test --project tests\Aspire.Hosting.Kubernetes.Tests\Aspire.Hosting.Kubernetes.Tests.csproj --no-launch-profile -- --filter-class "*.KubernetesPublisherTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true" - passed, 74 tests.
  • dotnet test --project tests\Aspire.Hosting.RemoteHost.Tests\Aspire.Hosting.RemoteHost.Tests.csproj --no-launch-profile -- --filter-method "*.WithField_DispatchesStructuredValuesToPublishedYaml" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true" with the original scalar union temporarily restored - failed as expected with requires handle of type 'String | Double | Boolean', got 'object'. The fix was restored before the passing runs.
  • git diff --check - passed.

The behavioral test dispatches real addManifest/withField capabilities through publishing and snapshots CiliumNetworkPolicy YAML: arrays of objects, dotted/slashed keys, empty arrays, booleans, replacement semantics, and fluent return identity. Rejection tests cover resource handles, nested non-finite JSON numbers, invalid dictionary keys, unsupported CLR objects, and non-finite CLR numbers, including preservation of existing fields on failure.

Evaluated MSBuild items/project references represent the new tests, snapshots, shared initializer, and Kubernetes dependency; no loose-input routing or workflow changes are needed.

Live Go Preview validation

Used the Linux x64 CLI archive and portable built-nugets from CI run 42116251464, both matching head 3603a49c38bd7de8336c971cc16352992ffe4669. CLI version: 17.0.0-pr.21824.g3603a49c. Ran in the existing aspire-go-e2e-6972:latest Docker image with Go 1.26.10, GCC 13.3.0, and a live Docker engine 29.9.2. No repository fixtures or shared Go runtime files were changed.

Exact commands inside the container (all passed):

/state/pr-cli/aspire new aspire-go-empty --name ManifestPreview --output /workspace/live-manifest --version 17.0.0-pr.21824.g3603a49c --source /workspace/portable-packages/Debug/Shipping --localhost-tld false --suppress-agent-init --use-config-source false --non-interactive
# Added Aspire.Hosting.Kubernetes 17.0.0-pr.21824.g3603a49c to the scratch aspire.config.json.
cd /workspace/live-manifest
/state/pr-cli/aspire restore --apphost apphost.go --non-interactive
go build ./...
(cd .aspire/modules && go build ./...)
/state/pr-cli/aspire publish --apphost apphost.go --output-path /workspace/published --non-interactive --include-exception-details
python3 /workspace/verify-output.py

The compile covers the complete generated Go module, not only the focused projection snapshot. Its generated WithField(path string, value any) accepts native Go maps/slices. The scratch AppHost uses PublishAsKubernetesService and the AddManifest Configure callback to author a CiliumNetworkPolicy. Publishing succeeded with 10/10 pipeline steps; a complete-output equality assertion verified templates/api/policy.yaml, including nested endpoint/port arrays, app.kubernetes.io/component and app.kubernetes.io/name keys, egress: [], ingress: true, and integer revision: 3.

The initial attempt without explicit version/source selected stable 13.6.4 and failed because Aspire.Hosting.Go has no matching stable package; the successful run above uses explicit matching PR artifacts. This does not claim default stable Go scaffolding is validated.

Not run: live TypeScript/Python/Java/Rust AppHosts or generated SDK compilation in those languages, Helm rendering, or deployment to a Kubernetes/Cilium cluster. Negative-value coverage remains the automated production dispatch/CLR tests, not live Go rejection scenarios. Callback-release and disconnect/os.Exit lifecycle redesigns are outside this change and this validation makes no new lifecycle guarantees.

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
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

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

github-actions Bot commented Nov 5, 2026

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 -- 21824

Or

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

@aspire-repo-bot
aspire-repo-bot Bot requested a balanced review from Copilot November 5, 2026 21:50
@github-actions github-actions Bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Nov 5, 2026
@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

Nested resource handles are silently serialized as unresolved $handle/$type objects, producing invalid manifest values; recursive rejection and tests covering handles inside objects and arrays are needed.

1 open issue
What changed in this PR

This PR addresses the remaining structured-manifest limitation in #18080, allowing polyglot AppHosts to supply nested Kubernetes fields without changing the CLR signature or dot-separated path behavior.

Changes:

  • Removes the scalar-only restriction from WithField and applies numeric validation to JSON values.
  • Adds dispatch-to-YAML tests, invalid-value tests, and generated SDK snapshots for five languages.
  • Documents custom manifests, dotted label keys, and subtree replacement behavior.
File Description
tests/​Aspire.Hosting.RemoteHost.Tests/​Snapshots/​KubernetesManifestTests.WithField_GeneratedSdkAcceptsStructuredValues_language=TypeScript.verified.ts Captures the TypeScript any parameter.
tests/​Aspire.Hosting.RemoteHost.Tests/​Snapshots/​KubernetesManifestTests.WithField_GeneratedSdkAcceptsStructuredValues_language=Rust.verified.rs Captures the Rust &Value parameter.
tests/​Aspire.Hosting.RemoteHost.Tests/​Snapshots/​KubernetesManifestTests.WithField_GeneratedSdkAcceptsStructuredValues_language=Python.verified.py Captures the Python typing.Any parameter.
tests/​Aspire.Hosting.RemoteHost.Tests/​Snapshots/​KubernetesManifestTests.WithField_GeneratedSdkAcceptsStructuredValues_language=Java.verified.java Captures the Java Object parameter.
tests/​Aspire.Hosting.RemoteHost.Tests/​Snapshots/​KubernetesManifestTests.WithField_GeneratedSdkAcceptsStructuredValues_language=Go.verified.go Captures Go generation without the scalar union guard.
tests/​Aspire.Hosting.RemoteHost.Tests/​Snapshots/​KubernetesManifestTests.WithField_DispatchesStructuredValuesToPublishedYaml.verified.yaml Records the published Cilium policy structure.
tests/​Aspire.Hosting.RemoteHost.Tests/​KubernetesManifestTests.cs Tests dispatch, publishing, rejection, and SDK projections.
tests/​Aspire.Hosting.RemoteHost.Tests/​Aspire.Hosting.RemoteHost.Tests.csproj Adds Kubernetes and snapshot-testing dependencies.
tests/​Aspire.Hosting.Kubernetes.Tests/​KubernetesPublisherTests.cs Tests invalid-value rejection and preservation of existing fields.
src/​Aspire.Hosting.Kubernetes/​README.md Documents structured custom-manifest usage.
src/​Aspire.Hosting.Kubernetes/​KubernetesManifestResource.cs Removes the union restriction and validates JSON numbers.

Review effort: Balanced

Preserve both Kubernetes README additions and reject ATS handle envelopes recursively before updating manifest fields. Cover nested object and array arguments and preserve existing fields on failure.

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

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Tests selector

7 / 101 PR test projects · 2 PR jobs, from 10 changed files.

Selected PR test projects (7 / 101)

Aspire.Cli.EndToEnd.Tests, Aspire.Hosting.Azure.Kubernetes.Tests, Aspire.Hosting.CodeGeneration.Python.Tests, Aspire.Hosting.CodeGeneration.TypeScript.Tests, Aspire.Hosting.Docker.Tests, Aspire.Hosting.Kubernetes.Tests, Aspire.Hosting.RemoteHost.Tests

Selected PR jobs (2)

polyglot, typescript-api-compat


How these were chosen — grouped by what changed

🔧 src/Aspire.Hosting.Kubernetes/KubernetesManifestResource.cs (changed source)
→ 1 directly: Aspire.Hosting.Kubernetes.Tests
→ 4 via the project graph: Aspire.Hosting.Azure.Kubernetes.Tests (2 hops), Aspire.Hosting.CodeGeneration.Python.Tests (2 hops), Aspire.Hosting.CodeGeneration.TypeScript.Tests, Aspire.Hosting.Docker.Tests

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

🧪 tests/Aspire.Hosting.Kubernetes.Tests/KubernetesPublisherTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Kubernetes.Tests

🧪 tests/Aspire.Hosting.RemoteHost.Tests/Aspire.Hosting.RemoteHost.Tests.csproj (changed test)
→ 1 directly: Aspire.Hosting.RemoteHost.Tests

🧪 tests/Aspire.Hosting.RemoteHost.Tests/KubernetesManifestTests.cs (changed test)
→ 1 directly: Aspire.Hosting.RemoteHost.Tests

🧪 tests/Aspire.Hosting.RemoteHost.Tests/Snapshots/KubernetesManifestTests.WithField_DispatchesStructuredValuesToPublishedYaml.verified.yaml (changed test)
→ 1 directly: Aspire.Hosting.RemoteHost.Tests

🧪 tests/Aspire.Hosting.RemoteHost.Tests/Snapshots/KubernetesManifestTests.WithField_GeneratedSdkAcceptsStructuredValues_language=Go.verified.go (changed test)
→ 1 directly: Aspire.Hosting.RemoteHost.Tests

🧪 tests/Aspire.Hosting.RemoteHost.Tests/Snapshots/KubernetesManifestTests.WithField_GeneratedSdkAcceptsStructuredValues_language=Java.verified.java (changed test)
→ 1 directly: Aspire.Hosting.RemoteHost.Tests

🧪 tests/Aspire.Hosting.RemoteHost.Tests/Snapshots/KubernetesManifestTests.WithField_GeneratedSdkAcceptsStructuredValues_language=Python.verified.py (changed test)
→ 1 directly: Aspire.Hosting.RemoteHost.Tests

🧪 tests/Aspire.Hosting.RemoteHost.Tests/Snapshots/KubernetesManifestTests.WithField_GeneratedSdkAcceptsStructuredValues_language=Rust.verified.rs (changed test)
→ 1 directly: Aspire.Hosting.RemoteHost.Tests

🧪 tests/Aspire.Hosting.RemoteHost.Tests/Snapshots/KubernetesManifestTests.WithField_GeneratedSdkAcceptsStructuredValues_language=TypeScript.verified.ts (changed test)
→ 1 directly: Aspire.Hosting.RemoteHost.Tests

Job reasons

Job Triggered by
polyglot • affected project Aspire.Hosting.Kubernetes
• affected project Aspire.Hosting.Azure.Provisioning.ContainerService
typescript-api-compat affected project Aspire.Hosting.Kubernetes

Selection computed for commit 0d3bc60.

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 approval of the structured Kubernetes manifest support.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@IEvangelist
David Pine (IEvangelist) merged commit dea22b1 into main Nov 6, 2026
181 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.0 milestone Nov 6, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Pull request created: #2072

Generated by PR Documentation Check · copilot · auto · 26.4 AIC · ⌖ 1.17 AIC · ⊞ 7.4K

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

📝 Documentation has been drafted in microsoft/aspire.dev#2072 targeting release/17.0.

Documented structured (object/array) withField values for Kubernetes custom manifests in integrations/compute/kubernetes.mdx. Signals: integration_readme_changed (Aspire.Hosting.Kubernetes README), pr_body_has_user_facing_section (User-facing usage example), pr_body_has_cli_flag_mention and pr_body_has_security_marker (false positives from validation dotnet test --project/vulnerability text).

Note

This draft PR needs human review before merging.

David Pine (IEvangelist) added a commit that referenced this pull request Nov 9, 2026
## Description

Generated Go AppHosts can run callbacks concurrently with the main
builder chain without racing the sticky error or lazy collection
accessors. Invalid request arguments and unencodable callback results
now fail their individual calls instead of disconnecting every pending
operation. Callback decoding errors and `runtime.Goexit` produce
explicit JSON-RPC errors; message headers and cancellation requests are
bounded.

The Go API export also includes structured `type` and `optional`
metadata for every field and constant. DTO optionality comes from ATS
metadata, not the generated `omitempty` tag or pointer spelling. This is
additive to schema version 1 and includes options, runtime fields, enum
constants, and exported value leaves. Export snapshots and the
output-format documentation are updated.

Related to #21204, #21212, and #21115. This does not close either
follow-up issue. The remaining structured Kubernetes manifest work is
separate in #21824.

### User-facing usage

Collection serialization preserves its existing signature; failures are
now observable through the additive `Err` methods:

```go
payload := resource.GetTags().ToJSON()
if err := resource.GetTags().Err(); err != nil {
    return err
}
_ = payload
```

`aspire sdk export --language go --package Name@Version` now emits
fields such as:

```json
{
  "name": "Mode",
  "type": "*TestPersistenceMode",
  "optional": true
}
```

Cancellation watchers are armed only after the invocation carrying their
IDs has entered the FIFO write queue. The cancellation RPC has a
five-second timeout; a canceled call still returns through its own
context without waiting for that RPC.

### Validation

Commands ran on Windows with the restored repository SDK and an isolated
Go 1.27.3 toolchain added to `PATH`. Linux race checks used Go 1.26.10
and GCC from the existing local `aspire-go-e2e-6972:latest` image.

| Command | Result |
| --- | --- |
| `.\restore.cmd` | Passed; 17 dependency audit warnings, no errors. |
| `dotnet 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"` | Passed: 130 tests, no failures or
skips. Reviewed and accepted generated Go/JSON snapshot changes. |
| `dotnet test --project
tests\Aspire.Hosting.CodeGeneration.Go.Tests\Aspire.Hosting.CodeGeneration.Go.Tests.csproj
--no-launch-profile -- --filter-method
"*.GeneratedRuntime_PassesGoRuntimeHardeningTests" --filter-not-trait
"quarantined=true" --filter-not-trait "outerloop=true"` | Passed after
adding the final actual-getter-failure assertions. |
| `go test -race -timeout 60s -v .` | Passed in a generated module
extracted from the Go snapshot, with `runtime_test.go`,
`transport_hardening_test.go`, and `decode_test.go` from the C# tests.
Includes a callback and main chaining on the same captured generated
builder, encoding failures, callback errors/Goexit, header bounds, and
cancellation ordering/timeout cleanup. |
| `go test -race -timeout 60s -run
TestCallbackAndMainCanChainOnCapturedBuilder .` | Failed as expected
against the original main snapshot with data races; the same regression
passes with this branch. |
| `dotnet test --project
tests\Aspire.Hosting.RemoteHost.Tests\Aspire.Hosting.RemoteHost.Tests.csproj
--no-launch-profile -- --filter-not-trait "quarantined=true"
--filter-not-trait "outerloop=true"` | Passed: 698 tests, 1 skipped.
Includes integration scanning and Go export/codegen coverage. |
| `dotnet test --project tests\Aspire.Cli.Tests\Aspire.Cli.Tests.csproj
--no-launch-profile -- --filter-class "*.SdkExportCommandTests"
--filter-not-trait "quarantined=true" --filter-not-trait
"outerloop=true"` | Passed: 31 tests. |
| `dotnet build src\Aspire.Cli\Aspire.Cli.csproj --configuration Release
/p:SkipNativeBuild=true` | Passed, with the existing ILCompiler audit
warning. Managed Release build, not native AOT. |
| `.\.dotnet\dotnet.exe
artifacts\bin\Aspire.Cli\Release\net11.0\aspire.dll sdk export --help` |
Passed; help lists Go as an export language. |
| `git diff --check` | Passed. |

### Remaining policy and execution gaps

- Callback registry release still needs a host release signal and a
cross-language ownership contract. This PR does not unregister callbacks
when a registration capability returns, because the host can invoke them
later.
- Disconnect-driven `os.Exit(1)` is unchanged. Choosing an observable
shutdown contract requires a cross-language decision; no GA lifecycle
guarantee is introduced.
- The reported required-token path is currently unreachable because
`SplitParameters` places all cancellation tokens in Go options. Both
token-emission paths select the supplied token's context.
- A bundled current-main CLI export measuring Redis/Azure Storage
XML-summary coverage was not run. No documentation-copy policy was
changed based solely on project-built behavior.
- No new grouped export view was introduced; consumers still have
`capabilityId` for grouping. The aspire.dev consumer and its grouping
decision are outside this product-only change.
- Native AOT publishing, the full CLI suite, a many-integration live
AppHost, polyglot E2E, macOS, and the complete CI matrix were not run.
Go feature-flag-off validation is obsolete because #21183 removed that
flag.

### Security considerations

This changes handling of AppHost JSON-RPC messages and callback
payloads. Headers are limited to 16 entries and 8 KiB before body
allocation, in addition to the existing 64 MiB body cap. Invalid typed
callback arguments are rejected before user code is called; decoding no
longer silently substitutes invalid DTO fields. No authentication,
listener, or permission policy changes are made. A formal threat
model/security review has not been performed.

## Checklist

- Is this feature complete?
  - [x] Yes. Ready to ship.
  - [ ] No. Follow-up changes expected.
- Are you including unit tests for the changes and scenario tests if
relevant?
  - [x] Yes
  - [ ] No
- Did you add public API?
  - [x] Yes
    - If yes, did you have an API Review for it?
      - [ ] Yes
      - [x] No
- Did you add `<remarks />` and `<code />` elements on your triple slash
comments?
      - [ ] Yes
      - [x] No
  - [ ] No
- Does the change make any security assumptions or guarantees?
  - [x] Yes
    - If yes, have you done a threat model and had a security review?
      - [ ] Yes
      - [x] No
  - [ ] No

The additive APIs are Go `List.Err`/`Dict.Err` and JSON export metadata;
no public C# API was added. Go documentation comments describe the error
contract. Triple-slash XML elements do not apply to these Go members.
The fixes in this PR are complete; the explicitly deferred
cross-language policy and bundle-validation items remain tracked in the
related issues.

---------

Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Mitch Denny (mitchdenny) pushed a commit that referenced this pull request Nov 10, 2026
## Description

Generated Go AppHosts can run callbacks concurrently with the main
builder chain without racing the sticky error or lazy collection
accessors. Invalid request arguments and unencodable callback results
now fail their individual calls instead of disconnecting every pending
operation. Callback decoding errors and `runtime.Goexit` produce
explicit JSON-RPC errors; message headers and cancellation requests are
bounded.

The Go API export also includes structured `type` and `optional`
metadata for every field and constant. DTO optionality comes from ATS
metadata, not the generated `omitempty` tag or pointer spelling. This is
additive to schema version 1 and includes options, runtime fields, enum
constants, and exported value leaves. Export snapshots and the
output-format documentation are updated.

Related to #21204, #21212, and #21115. This does not close either
follow-up issue. The remaining structured Kubernetes manifest work is
separate in #21824.

### User-facing usage

Collection serialization preserves its existing signature; failures are
now observable through the additive `Err` methods:

```go
payload := resource.GetTags().ToJSON()
if err := resource.GetTags().Err(); err != nil {
    return err
}
_ = payload
```

`aspire sdk export --language go --package Name@Version` now emits
fields such as:

```json
{
  "name": "Mode",
  "type": "*TestPersistenceMode",
  "optional": true
}
```

Cancellation watchers are armed only after the invocation carrying their
IDs has entered the FIFO write queue. The cancellation RPC has a
five-second timeout; a canceled call still returns through its own
context without waiting for that RPC.

### Validation

Commands ran on Windows with the restored repository SDK and an isolated
Go 1.27.3 toolchain added to `PATH`. Linux race checks used Go 1.26.10
and GCC from the existing local `aspire-go-e2e-6972:latest` image.

| Command | Result |
| --- | --- |
| `.\restore.cmd` | Passed; 17 dependency audit warnings, no errors. |
| `dotnet 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"` | Passed: 130 tests, no failures or
skips. Reviewed and accepted generated Go/JSON snapshot changes. |
| `dotnet test --project
tests\Aspire.Hosting.CodeGeneration.Go.Tests\Aspire.Hosting.CodeGeneration.Go.Tests.csproj
--no-launch-profile -- --filter-method
"*.GeneratedRuntime_PassesGoRuntimeHardeningTests" --filter-not-trait
"quarantined=true" --filter-not-trait "outerloop=true"` | Passed after
adding the final actual-getter-failure assertions. |
| `go test -race -timeout 60s -v .` | Passed in a generated module
extracted from the Go snapshot, with `runtime_test.go`,
`transport_hardening_test.go`, and `decode_test.go` from the C# tests.
Includes a callback and main chaining on the same captured generated
builder, encoding failures, callback errors/Goexit, header bounds, and
cancellation ordering/timeout cleanup. |
| `go test -race -timeout 60s -run
TestCallbackAndMainCanChainOnCapturedBuilder .` | Failed as expected
against the original main snapshot with data races; the same regression
passes with this branch. |
| `dotnet test --project
tests\Aspire.Hosting.RemoteHost.Tests\Aspire.Hosting.RemoteHost.Tests.csproj
--no-launch-profile -- --filter-not-trait "quarantined=true"
--filter-not-trait "outerloop=true"` | Passed: 698 tests, 1 skipped.
Includes integration scanning and Go export/codegen coverage. |
| `dotnet test --project tests\Aspire.Cli.Tests\Aspire.Cli.Tests.csproj
--no-launch-profile -- --filter-class "*.SdkExportCommandTests"
--filter-not-trait "quarantined=true" --filter-not-trait
"outerloop=true"` | Passed: 31 tests. |
| `dotnet build src\Aspire.Cli\Aspire.Cli.csproj --configuration Release
/p:SkipNativeBuild=true` | Passed, with the existing ILCompiler audit
warning. Managed Release build, not native AOT. |
| `.\.dotnet\dotnet.exe
artifacts\bin\Aspire.Cli\Release\net11.0\aspire.dll sdk export --help` |
Passed; help lists Go as an export language. |
| `git diff --check` | Passed. |

### Remaining policy and execution gaps

- Callback registry release still needs a host release signal and a
cross-language ownership contract. This PR does not unregister callbacks
when a registration capability returns, because the host can invoke them
later.
- Disconnect-driven `os.Exit(1)` is unchanged. Choosing an observable
shutdown contract requires a cross-language decision; no GA lifecycle
guarantee is introduced.
- The reported required-token path is currently unreachable because
`SplitParameters` places all cancellation tokens in Go options. Both
token-emission paths select the supplied token's context.
- A bundled current-main CLI export measuring Redis/Azure Storage
XML-summary coverage was not run. No documentation-copy policy was
changed based solely on project-built behavior.
- No new grouped export view was introduced; consumers still have
`capabilityId` for grouping. The aspire.dev consumer and its grouping
decision are outside this product-only change.
- Native AOT publishing, the full CLI suite, a many-integration live
AppHost, polyglot E2E, macOS, and the complete CI matrix were not run.
Go feature-flag-off validation is obsolete because #21183 removed that
flag.

### Security considerations

This changes handling of AppHost JSON-RPC messages and callback
payloads. Headers are limited to 16 entries and 8 KiB before body
allocation, in addition to the existing 64 MiB body cap. Invalid typed
callback arguments are rejected before user code is called; decoding no
longer silently substitutes invalid DTO fields. No authentication,
listener, or permission policy changes are made. A formal threat
model/security review has not been performed.

## Checklist

- Is this feature complete?
  - [x] Yes. Ready to ship.
  - [ ] No. Follow-up changes expected.
- Are you including unit tests for the changes and scenario tests if
relevant?
  - [x] Yes
  - [ ] No
- Did you add public API?
  - [x] Yes
    - If yes, did you have an API Review for it?
      - [ ] Yes
      - [x] No
- Did you add `<remarks />` and `<code />` elements on your triple slash
comments?
      - [ ] Yes
      - [x] No
  - [ ] No
- Does the change make any security assumptions or guarantees?
  - [x] Yes
    - If yes, have you done a threat model and had a security review?
      - [ ] Yes
      - [x] No
  - [ ] No

The additive APIs are Go `List.Err`/`Dict.Err` and JSON export metadata;
no public C# API was added. Go documentation comments describe the error
contract. Triple-slash XML elements do not apply to these Go members.
The fixes in this PR are complete; the explicitly deferred
cross-language policy and bundle-validation items remain tracked in the
related issues.

---------

Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
(cherry picked from commit e7ff435)
Mitch Denny (mitchdenny) pushed a commit that referenced this pull request Nov 10, 2026
## Description

Generated Go AppHosts can run callbacks concurrently with the main
builder chain without racing the sticky error or lazy collection
accessors. Invalid request arguments and unencodable callback results
now fail their individual calls instead of disconnecting every pending
operation. Callback decoding errors and `runtime.Goexit` produce
explicit JSON-RPC errors; message headers and cancellation requests are
bounded.

The Go API export also includes structured `type` and `optional`
metadata for every field and constant. DTO optionality comes from ATS
metadata, not the generated `omitempty` tag or pointer spelling. This is
additive to schema version 1 and includes options, runtime fields, enum
constants, and exported value leaves. Export snapshots and the
output-format documentation are updated.

Related to #21204, #21212, and #21115. This does not close either
follow-up issue. The remaining structured Kubernetes manifest work is
separate in #21824.

### User-facing usage

Collection serialization preserves its existing signature; failures are
now observable through the additive `Err` methods:

```go
payload := resource.GetTags().ToJSON()
if err := resource.GetTags().Err(); err != nil {
    return err
}
_ = payload
```

`aspire sdk export --language go --package Name@Version` now emits
fields such as:

```json
{
  "name": "Mode",
  "type": "*TestPersistenceMode",
  "optional": true
}
```

Cancellation watchers are armed only after the invocation carrying their
IDs has entered the FIFO write queue. The cancellation RPC has a
five-second timeout; a canceled call still returns through its own
context without waiting for that RPC.

### Validation

Commands ran on Windows with the restored repository SDK and an isolated
Go 1.27.3 toolchain added to `PATH`. Linux race checks used Go 1.26.10
and GCC from the existing local `aspire-go-e2e-6972:latest` image.

| Command | Result |
| --- | --- |
| `.\restore.cmd` | Passed; 17 dependency audit warnings, no errors. |
| `dotnet 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"` | Passed: 130 tests, no failures or
skips. Reviewed and accepted generated Go/JSON snapshot changes. |
| `dotnet test --project
tests\Aspire.Hosting.CodeGeneration.Go.Tests\Aspire.Hosting.CodeGeneration.Go.Tests.csproj
--no-launch-profile -- --filter-method
"*.GeneratedRuntime_PassesGoRuntimeHardeningTests" --filter-not-trait
"quarantined=true" --filter-not-trait "outerloop=true"` | Passed after
adding the final actual-getter-failure assertions. |
| `go test -race -timeout 60s -v .` | Passed in a generated module
extracted from the Go snapshot, with `runtime_test.go`,
`transport_hardening_test.go`, and `decode_test.go` from the C# tests.
Includes a callback and main chaining on the same captured generated
builder, encoding failures, callback errors/Goexit, header bounds, and
cancellation ordering/timeout cleanup. |
| `go test -race -timeout 60s -run
TestCallbackAndMainCanChainOnCapturedBuilder .` | Failed as expected
against the original main snapshot with data races; the same regression
passes with this branch. |
| `dotnet test --project
tests\Aspire.Hosting.RemoteHost.Tests\Aspire.Hosting.RemoteHost.Tests.csproj
--no-launch-profile -- --filter-not-trait "quarantined=true"
--filter-not-trait "outerloop=true"` | Passed: 698 tests, 1 skipped.
Includes integration scanning and Go export/codegen coverage. |
| `dotnet test --project tests\Aspire.Cli.Tests\Aspire.Cli.Tests.csproj
--no-launch-profile -- --filter-class "*.SdkExportCommandTests"
--filter-not-trait "quarantined=true" --filter-not-trait
"outerloop=true"` | Passed: 31 tests. |
| `dotnet build src\Aspire.Cli\Aspire.Cli.csproj --configuration Release
/p:SkipNativeBuild=true` | Passed, with the existing ILCompiler audit
warning. Managed Release build, not native AOT. |
| `.\.dotnet\dotnet.exe
artifacts\bin\Aspire.Cli\Release\net11.0\aspire.dll sdk export --help` |
Passed; help lists Go as an export language. |
| `git diff --check` | Passed. |

### Remaining policy and execution gaps

- Callback registry release still needs a host release signal and a
cross-language ownership contract. This PR does not unregister callbacks
when a registration capability returns, because the host can invoke them
later.
- Disconnect-driven `os.Exit(1)` is unchanged. Choosing an observable
shutdown contract requires a cross-language decision; no GA lifecycle
guarantee is introduced.
- The reported required-token path is currently unreachable because
`SplitParameters` places all cancellation tokens in Go options. Both
token-emission paths select the supplied token's context.
- A bundled current-main CLI export measuring Redis/Azure Storage
XML-summary coverage was not run. No documentation-copy policy was
changed based solely on project-built behavior.
- No new grouped export view was introduced; consumers still have
`capabilityId` for grouping. The aspire.dev consumer and its grouping
decision are outside this product-only change.
- Native AOT publishing, the full CLI suite, a many-integration live
AppHost, polyglot E2E, macOS, and the complete CI matrix were not run.
Go feature-flag-off validation is obsolete because #21183 removed that
flag.

### Security considerations

This changes handling of AppHost JSON-RPC messages and callback
payloads. Headers are limited to 16 entries and 8 KiB before body
allocation, in addition to the existing 64 MiB body cap. Invalid typed
callback arguments are rejected before user code is called; decoding no
longer silently substitutes invalid DTO fields. No authentication,
listener, or permission policy changes are made. A formal threat
model/security review has not been performed.

## Checklist

- Is this feature complete?
  - [x] Yes. Ready to ship.
  - [ ] No. Follow-up changes expected.
- Are you including unit tests for the changes and scenario tests if
relevant?
  - [x] Yes
  - [ ] No
- Did you add public API?
  - [x] Yes
    - If yes, did you have an API Review for it?
      - [ ] Yes
      - [x] No
- Did you add `<remarks />` and `<code />` elements on your triple slash
comments?
      - [ ] Yes
      - [x] No
  - [ ] No
- Does the change make any security assumptions or guarantees?
  - [x] Yes
    - If yes, have you done a threat model and had a security review?
      - [ ] Yes
      - [x] No
  - [ ] No

The additive APIs are Go `List.Err`/`Dict.Err` and JSON export metadata;
no public C# API was added. Go documentation comments describe the error
contract. Triple-slash XML elements do not apply to these Go members.
The fixes in this PR are complete; the explicitly deferred
cross-language policy and bundle-validation items remain tracked in the
related issues.

---------

Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
(cherry picked from commit e7ff435)
@IEvangelist

Copy link
Copy Markdown
Member Author

/backport to release/17.0

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/17.0 (link to workflow run)

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

David Pine (@IEvangelist) backporting to release/17.0 failed, the patch most likely resulted in conflicts. Please backport manually!

git am output
$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Allow structured Kubernetes manifest field values
Using index info to reconstruct a base tree...
M	src/Aspire.Hosting.Kubernetes/README.md
M	tests/Aspire.Hosting.Kubernetes.Tests/KubernetesPublisherTests.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Aspire.Hosting.Kubernetes/README.md
CONFLICT (content): Merge conflict in src/Aspire.Hosting.Kubernetes/README.md
Auto-merging tests/Aspire.Hosting.Kubernetes.Tests/KubernetesPublisherTests.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Allow structured Kubernetes manifest field values
Error: The process '/usr/bin/git' failed with exit code 128

Link to workflow output

Jose Perez Rodriguez (joperezr) pushed a commit that referenced this pull request Nov 11, 2026
)

## Description

Backport of #21824 to `release/17.0`.

Polyglot AppHosts can author custom Kubernetes manifests with nested
objects and arrays, including CiliumNetworkPolicy ingress rules and
selectors whose label keys contain dots and slashes. JSON numbers
receive the same finite/range checks as CLR numeric values, including
inside nested structures. Dot-separated paths and last-write-wins
behavior are unchanged; no public CLR API is added.

This standalone backport applies the final merged squash commit
`dea22b13453b1703ace03f23c06bfd013017edb6`, not the original
multi-commit patch history. It applied cleanly to release tip
`cec195f2d0bf3f1d714badf74f205fa855fdf963` without conflict resolution
or adaptations. It does not depend on or modify the abandoned stacked
backports, including #22001.

Relates to #18080; this addresses structured manifest values only and
does not close the umbrella issue.

### User-facing usage

```typescript
await api.publishAsKubernetesService(async (service) => {
    const policy = await service.addManifest("cilium.io/v2", "CiliumNetworkPolicy", "api-netpol");
    await policy.withField("spec.endpointSelector.matchLabels", {
        "app.kubernetes.io/component": "api"
    });
    await policy.withField("spec.ingress", [{
        fromEndpoints: [{
            matchLabels: { "app.kubernetes.io/component": "frontend" }
        }]
    }]);
});
```

### Validation

Run against this release-branch backport on Windows:

- `.\restore.cmd` - passed (0 errors, 18 NuGet vulnerability warnings).
- `dotnet test --project
tests\Aspire.Hosting.RemoteHost.Tests\Aspire.Hosting.RemoteHost.Tests.csproj
--no-launch-profile -- --filter-class "*.KubernetesManifestTests"
--filter-not-trait "quarantined=true" --filter-not-trait
"outerloop=true"` - passed, 13 tests; 0 failed/skipped.
- `dotnet test --project
tests\Aspire.Hosting.Kubernetes.Tests\Aspire.Hosting.Kubernetes.Tests.csproj
--no-launch-profile -- --filter-class "*.KubernetesPublisherTests"
--filter-not-trait "quarantined=true" --filter-not-trait
"outerloop=true"` - passed, 115 tests; 0 failed/skipped.
- `git diff --check HEAD^ HEAD` - passed.
- `git diff HEAD^ HEAD | git patch-id --stable` and `git diff
dea22b1^
dea22b1 | git patch-id --stable` -
passed equivalence check: both patch IDs are
`26cc4688082766ec12213ef758509ce1b4153169`.
- `git diff --exit-code` and `git status --short` - passed/clean after
tests; no snapshot changes accepted.

No local build/test blockers. Live AppHosts, Helm rendering, and
Kubernetes/Cilium deployment were not rerun for this backport; CI was
pending when the PR was created. The added test dependency is an
explicit MSBuild project reference, with tests and snapshots in their
owning project; no test-selection map changes are required.

## Checklist

- Is this feature complete?
  - [x] Yes. Ready to ship.
  - [ ] No. Follow-up changes expected.
- Are you including unit tests for the changes and scenario tests if
relevant?
  - [x] Yes
  - [ ] No
- Did you add public API?
  - [ ] Yes
    - If yes, did you have an API Review for it?
      - [ ] Yes
      - [ ] No
- Did you add `<remarks />` and `<code />` elements on your triple slash
comments?
      - [ ] Yes
      - [ ] No
  - [x] No
- Does the change make any security assumptions or guarantees?
  - [ ] Yes
    - If yes, have you done a threat model and had a security review?
      - [ ] Yes
      - [ ] No
  - [x] No

## Customer Impact

Polyglot AppHosts, including Go, cannot author Kubernetes
custom-resource fields containing nested objects or arrays, blocking
scenarios such as CiliumNetworkPolicy rules and dotted/slashed label
keys.

## Testing

On this release-branch backport, KubernetesManifestTests passed 13 tests
and KubernetesPublisherTests passed 115 tests. The patch exactly matches
the merged source, with no snapshot updates. Exact commands and results
are recorded above.

## Risk

Low. Localized manifest-value handling with unchanged CLR signature,
capability ID, field paths, and replacement behavior.

## Regression?

Unknown. The source PR does not establish a regression.

Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Mitch Denny (mitchdenny) added a commit to microsoft/aspire.dev that referenced this pull request Nov 17, 2026
Documents changes from microsoft/aspire#21824

Author: ``@davidfowl-unknown``

Targeting `release/17.0` based on the source PR milestone `17.0`
(target_resolution: `exact_match`).

## Why
`KubernetesManifestResource.WithField` no longer restricts polyglot
values to scalars; objects and arrays (e.g. CiliumNetworkPolicy
selectors with dotted keys) are now accepted. The docs previously didn't
describe this.

## Changes
- Updated
`src/frontend/src/content/docs/integrations/compute/kubernetes.mdx`
(existing page): added a "Structured field values" section with a
TypeScript example, dotted-key guidance, replace semantics, and the
resource-handle limitation.

> Generated by [PR Documentation
Check](https://github.com/microsoft/aspire/actions/runs/42168191345) for
#21824 · copilot · auto · 26.4 AIC · ⌖ 1.17 AIC · ⊞ 7.4K ·
[◷](https://github.com/search?q=repo%3Amicrosoft%2Faspire.dev+%22gh-aw-workflow-id%3A+pr-docs-check%22&type=pullrequests)

<!-- gh-aw-agentic-workflow: PR Documentation Check, engine: copilot,
model: auto, id: 42168191345, workflow_id: pr-docs-check, run:
https://github.com/microsoft/aspire/actions/runs/42168191345 -->

<!-- gh-aw-workflow-id: pr-docs-check -->
<!-- gh-aw-workflow-call-id: microsoft/aspire/pr-docs-check -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants