Skip to content

Use exported TypeScript names in Kubernetes Ingress/Gateway samples - #2002

Merged
David Pine (IEvangelist) merged 1 commit into
mainfrom
aspireagent/fix-k8s-ingress-gateway-ts-apis
Nov 1, 2026
Merged

David Pine (IEvangelist) merged 1 commit into
mainfrom
aspireagent/fix-k8s-ingress-gateway-ts-apis

Conversation

@davidfowl

Copy link
Copy Markdown
Contributor

Summary

The TypeScript AppHost samples for Kubernetes Ingress and Gateway routing use the C# overload names. Those names don't exist in the TypeScript AppHost SDK, so a reader who copies the samples hits withPath is not a function (or sends the wrong argument type).

In the TypeScript SDK, each C# overload is exported under its own capability name. Upstream microsoft/aspire main (c77b0c13c34616d1ce4698771bdd445fd50c7a99) defines them in KubernetesIngressExtensions.cs, KubernetesGatewayExtensions.cs and CertManagerExtensions.cs. The in-repo src/data/ts-modules/Aspire.Hosting.Kubernetes.*.json surface matches them.

C# overload Upstream [AspireExport] TS sample before TS sample after
WithPath(path, endpoint) withIngressPath ingress.withPath(...) ingress.withIngressPath(...)
WithTls() (Ingress) withIngressTlsAuto ingress.withTls() (TS withTls requires secretName) ingress.withIngressTlsAuto()
WithIngressClass(IResourceBuilder<ParameterResource>) withIngressClassParam ingress.withIngressClass(param) ingress.withIngressClassParam(param)
WithHostname(IResourceBuilder<ParameterResource>) (Ingress) withIngressHostnameParam ingress.withHostname(param) ingress.withIngressHostnameParam(param)
WithRoute(path, endpoint) withGatewayPathRoute storefront.withRoute(...) storefront.withGatewayPathRoute(...)
WithTls(issuer) (Gateway) withGatewayTlsIssuer storefront.withTls(letsencrypt) storefront.withGatewayTlsIssuer(letsencrypt)
WithHostname(IResourceBuilder<ParameterResource>) (Gateway) withGatewayHostnameParam storefront.withHostname(param) storefront.withGatewayHostnameParam(param)

Upstream's own TypeScript polyglot AppHost uses the same names, for example gateway.withGatewayTlsIssuer(stagingIssuer) in tests/PolyglotAppHosts/Aspire.Hosting.Kubernetes/TypeScript/apphost.mts.

This PR changes 15 sample lines in 6 TypeScript blocks:

  • deployment/kubernetes-ingress.mdx: 3 blocks.
  • deployment/kubernetes/aks.mdx: 3 blocks.

The C# samples and the prose are unchanged.

How this was found

I ran a systematic TypeScript AppHost drift audit across all docs:

  • Scope: 1,264 TS fences in 611 files. 398 are twoslash blocks, which the build already type-checks.
  • Type-check: I compiled the remaining 635 AppHost blocks (507 full samples, 128 fragments) against src/data/twoslash/aspire.d.ts with the repo's twoslash compiler options. That produced 202 English diagnostics.
  • Triage:
    • Argument-shape diagnostics were mostly gaps in the local .d.ts generator, not sample errors. For example, upstream emits options objects for all optional parameters, so calls like runAsEmulator({ configureContainer }) are correct.
    • Name-level diagnostics were checked against the ts-modules data and upstream source.
    • The Ingress/Gateway names are the confirmed group fixed here.
    • addAzureCosmosDb is already handled by Use addAzureCosmosDB in the EF Core Cosmos DB TypeScript AppHost samples #2001.

Regression test

The new tests/unit/typescript-kubernetes-routing-apis.vitest.test.ts scans the TypeScript samples in the English docs for addIngress/addGateway resources. It checks each call on them against the ts-modules surface for KubernetesIngressResource/KubernetesGatewayResource, including inherited interface targets. It flags:

  • methods that aren't exported;
  • calls with fewer arguments than the required parameters;
  • resource variables passed where a string is required.

On main it fails with 14 problems:

deployment/kubernetes/aks.mdx:311: withRoute is not exported for KubernetesGatewayResource
deployment/kubernetes/aks.mdx:360: withRoute is not exported for KubernetesGatewayResource
deployment/kubernetes/aks.mdx:361: withTls expects a string but got resource letsencrypt
deployment/kubernetes/aks.mdx:458: withHostname expects a string but got resource hostname
deployment/kubernetes/aks.mdx:459: withRoute is not exported for KubernetesGatewayResource
deployment/kubernetes-ingress.mdx:100: withTls expects 1 argument(s) but got 0
deployment/kubernetes-ingress.mdx:103: withPath is not exported for KubernetesIngressResource
deployment/kubernetes-ingress.mdx:104: withPath is not exported for KubernetesIngressResource
deployment/kubernetes-ingress.mdx:137: withTls expects 1 argument(s) but got 0
deployment/kubernetes-ingress.mdx:140: withPath is not exported for KubernetesIngressResource
deployment/kubernetes-ingress.mdx:141: withPath is not exported for KubernetesIngressResource
deployment/kubernetes-ingress.mdx:198: withIngressClass expects a string but got resource ingressClass
deployment/kubernetes-ingress.mdx:199: withHostname expects a string but got resource hostname
deployment/kubernetes-ingress.mdx:200: withTls expects 1 argument(s) but got 0

With this change, the test passes.

The 15th line, aks.mdx:460 (withTls(letsencrypt) → withGatewayTlsIssuer), is the same issuer drift. The test doesn't detect it because that snippet reuses letsencrypt from an earlier block without declaring it.

Screenshots

The only visual change is the rendered TypeScript tab text. Captures are Playwright, desktop 1280×900, light theme, against a local dev server.

Before (main) After
Kubernetes Ingress — Routing paths to services (desktop, light) Before: Ingress TypeScript sample uses withTls() and withPath After: Ingress TypeScript sample uses withIngressTlsAuto() and withIngressPath
AKS — Add automatic HTTPS with cert-manager (desktop, light) Before: Gateway TypeScript sample uses withRoute and withTls(letsencrypt) After: Gateway TypeScript sample uses withGatewayPathRoute and withGatewayTlsIssuer

Out of scope

The TypeScript samples in kubernetes-ingress-aks.mdx and kubernetes-gateway-aks.mdx use a different, non-canonical shape (import { DistributedApplication } from "@aspire/apphost" with synchronous chaining). Correcting them needs a sample rewrite rather than a rename, so I left them for a separate change.

Overlap check: no open issue or PR mentions these names. #1996 and #1868 touch other Kubernetes pages but not these samples.

Third-party links and affiliations

None. The links above point to microsoft/aspire source.

Validation

  • npx vitest run tests/unit/typescript-kubernetes-routing-apis.vitest.test.ts: fails on main (14 problems above) and passes with this change.
  • npx vitest run: 85 files, 1,121 passed, 1 skipped.
  • npx eslint . --max-warnings 0: clean.
  • npx prettier --check on the new test: clean. The two .mdx files already have Prettier warnings on main, unchanged by this PR.
  • Playwright before/after screenshots above.

🤖 Posted by AspireAgent (AI Agent)

The TypeScript AppHost samples for Kubernetes Ingress and Gateway routing
copied the C# overload names, which the TypeScript SDK exports under
distinct capability names:

- WithPath -> withIngressPath
- WithRoute -> withGatewayPathRoute
- WithTls() -> withIngressTlsAuto()
- WithTls(issuer) -> withGatewayTlsIssuer(issuer)
- WithIngressClass/WithHostname(parameter) -> withIngressClassParam /
  withIngressHostnameParam / withGatewayHostnameParam

Add a unit test that checks Ingress/Gateway calls in TypeScript samples
against the generated ts-modules API surface.

Co-authored-by: Copilot <[email protected]>
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Frontend HTML artifact ready

The latest frontend build uploaded the frontend-dist artifact for PR #2002. Use the VS Code button below to open this PR with GitHub Artifacts Explorer and browse the built HTML locally.

VS Code: Open PR #2002 artifacts

This comment updates automatically when a new frontend build artifact is uploaded.

@davidfowl
David Fowler (davidfowl) marked this pull request as ready for review October 30, 2026 17:58
Copilot AI balanced review requested due to automatic review settings October 30, 2026 17:58

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

There are no active review issues for the TypeScript Kubernetes routing sample corrections and accompanying regression test.

No open issues 🎉

What changed in this PR

This PR corrects Kubernetes Ingress and Gateway TypeScript AppHost samples to use exported SDK method names, addressing API-name and argument-shape drift without changing C# samples or prose.

Changes:

  • Updates 15 sample lines across six TypeScript blocks to use the appropriate routing, TLS, and parameter-based methods.
  • Adds a regression test that checks recognized Ingress/Gateway calls in English documentation against generated API metadata for exported names, required arguments, and resource-to-string mismatches.
File Description
src/​frontend/​tests/​unit/​typescript-kubernetes-routing-apis.vitest.test.ts Adds API-surface regression checks for TypeScript routing samples.
src/​frontend/​src/​content/​docs/​deployment/​kubernetes/​aks.mdx Corrects Gateway routing, TLS issuer, and hostname parameter calls.
src/​frontend/​src/​content/​docs/​deployment/​kubernetes-ingress.mdx Corrects Ingress path, automatic TLS, and parameter-based calls.

Review effort: Balanced

@IEvangelist
David Pine (IEvangelist) enabled auto-merge (squash) November 1, 2026 14:27
@IEvangelist
David Pine (IEvangelist) merged commit 00aa17f into main Nov 1, 2026
20 checks passed
@IEvangelist
David Pine (IEvangelist) deleted the aspireagent/fix-k8s-ingress-gateway-ts-apis branch November 1, 2026 14:28
@IEvangelist

Copy link
Copy Markdown
Member

Documentation accuracy review [partial — phase A: 15 of 15 changed call claims evaluated; phase B: browser and syntax checks completed, semantic/model/publish validation blocked]

Reviewed PR #2002 against main, head aa06984d454e099fdf87717cb139ea404a231966, base f05f5561b1b858344124cd848ff06469627d7e6e. This is a conversation report, not a formal approval or change-request verdict.

Publication note (2026-11-01): the PR merged while this review was paused. The inspected head is unchanged; this report records the requested historical review, not a pre-merge gate.

Phase A: 15 changed sample-call claims: 15 verified, 0 verified-with-nuance, 0 unverifiable, 0 contradicted. The explanatory API-name claim in the new regression test agrees with the same owning-source exports. Source reads: microsoft/aspire main pinned at 6a8f53125b8788df3c409088381057a3c0dacfff, plus version-matched release/13.6 source commit f4c27f2d43ddc1cacd0dd083b30d1fea1cee7a62, identified by the PR's 13.6 Kubernetes module provenance and confirmed through owning-source reads. These are distinct, diverged refs, not interchangeable snapshots. Both were checked for the changed routing export names; evidence below uses the version-matched commit. No changed claim needed Community Toolkit or Azure SDK source.

Phase B: Independent, source-blind doc-tester exercised the two actual PR pages at http://localhost:4322. Seven copied blocks passed syntax-only checks; no critical defect was demonstrated. Compatible TypeScript AppHost preparation failed, so execution, generated manifests and deployment behavior remain unverified. The API-name correction is evidenced by source; this is not an end-to-end certification.

Phase A — Claim verification

No contradicted or unverifiable changed call was found.

All 15 changed call claims and owning-source evidence

Paths in the location column are relative to src/frontend/src/content/docs/deployment/. Source links pin microsoft/aspire at f4c27f2d43ddc1cacd0dd083b30d1fea1cee7a62.

Claim PR location Exact call / verified contract Source evidence
A01 kubernetes-ingress.mdx:100 await ingress.withIngressTlsAuto(); — no required user argument; secret name is derived from the ingress name. Ingress exports, lines 283–294
A02 kubernetes-ingress.mdx:103 await ingress.withIngressPath('/api', api.getEndpoint('http')); — required path and endpoint, default Prefix match. Ingress path, lines 118–140
A03 kubernetes-ingress.mdx:104 await ingress.withIngressPath('/', web.getEndpoint('http')); — root path and endpoint. Ingress path, lines 118–140
A04 kubernetes-ingress.mdx:137 await ingress.withIngressTlsAuto(); — no required user argument. Ingress TLS, lines 283–294
A05 kubernetes-ingress.mdx:140 await ingress.withIngressPath('/api', api.getEndpoint('http')); — hostname inheritance retained. Export/signature, hostname materialization, lines 785–806
A06 kubernetes-ingress.mdx:141 await ingress.withIngressPath('/', web.getEndpoint('http')); — hostname inheritance retained. Export/signature, hostname materialization
A07 kubernetes-ingress.mdx:198 ingress.withIngressClassParam(ingressClass); — accepts a parameter resource, not a string overload. Parameter class, lines 89–98
A08 kubernetes-ingress.mdx:199 ingress.withIngressHostnameParam(hostname); — parameter resource feeds the hostname reference. Parameter hostname, lines 221–230
A09 kubernetes-ingress.mdx:200 ingress.withIngressTlsAuto(); — no required user argument. Ingress TLS, lines 283–294
A10 kubernetes/aks.mdx:311 await storefront.withGatewayPathRoute('/', api.getEndpoint('http')); — required path and endpoint, default PathPrefix. Gateway path, lines 103–125
A11 kubernetes/aks.mdx:360 await storefront.withGatewayPathRoute('/', api.getEndpoint('http')); — same path contract. Gateway path, lines 103–125
A12 kubernetes/aks.mdx:361 await storefront.withGatewayTlsIssuer(letsencrypt); — requires a CertManagerIssuerResource, validates the Kubernetes environment, adds auto TLS and issuer annotation. Issuer export and validation, lines 330–352
A13 kubernetes/aks.mdx:458 await storefront.withGatewayHostnameParam(hostname); — parameter resource feeds route/listener hostname. Gateway hostname, lines 196–205, listener, HTTPRoute
A14 kubernetes/aks.mdx:459 await storefront.withGatewayPathRoute('/', api.getEndpoint('http')); — same path contract. Gateway path, lines 103–125
A15 kubernetes/aks.mdx:460 await storefront.withGatewayTlsIssuer(letsencrypt); — same typed issuer contract. Issuer export and validation, lines 330–352

Additional contract evidence: AKS Gateway delegates to the inner Kubernetes environment, AKS cert-manager delegates to the same environment, polyglot parameter dispatcher, generator resolves promise-compatible handle arguments, and generated fluent promises track their underlying work. Therefore un-awaited parameter creation is not by itself evidence of a wrong resource argument.

No Aspire version string was added or edited. Surrounding unchanged prose/examples are context, not additional changed-claim findings.

Phase B — Independent doc-tester results (verbatim)

Documentation Test Report — Frozen Phase B

Focus Area: PR #2002: TypeScript Ingress TLS/path/parameter examples and AKS Gateway path/TLS issuer/hostname parameter examples
Date: 2026-10-31
Tester: Independent doc-tester agent
Result: Partial validation; runtime/model/publish checks blocked by installed Aspire tooling.

Served identity

No product source, site tests, generated API metadata, or Phase A findings were inspected. No GitHub comments were posted.

Summary

Category Passed Failed Warnings / limitations
Content accuracy Not runtime-verified No demonstrated critical defect Terminology mapping unclear
Code examples 7 syntax-only checks 0 syntax failures Type checking and execution blocked
CLI commands Local site restored and served 2 project-preparation attempts failed Environment/toolchain failures
Links 15 browser targets returned HTTP 200 0 observed failures API-reference targets intentionally excluded

Critical Issues

None demonstrated. This is not an assertion that the APIs or deployment behavior are correct: the required runtime validation could not be completed.

Warnings

Warning 1: A compatible TypeScript runtime could not be prepared

Location: Both scoped pages; prerequisite/project setup for executable examples.

Installed Aspire was:

13.4.0+3f0998a95833d5fef96b3159d56b667889b71166

The Ingress page explicitly states:

“This inheritance behavior applies from Aspire 13.6 onward.”

The default starter preparation failed because its staging package source returned 404s and could not restore Aspire.Hosting, Aspire.Hosting.JavaScript, or Aspire.Hosting.CodeGeneration.TypeScript.

A stable 13.6.4 retry failed with:

“The installed Aspire CLI version (13.4.0) differs from the configured Aspire SDK version (13.6.4).”

“No code generator found for language: TypeScript.”

Impact: No valid TypeScript AppHost was available for type checking, model evaluation, or publishing. These failures are environment limitations, not newly demonstrated documentation defects.

Helm was also unavailable on PATH. No global installation or update was performed.

Warning 2: TypeScript method names are not consistently explained by nearby prose

Locations:

  • /deployment/kubernetes-ingress/#routing-paths-to-services
  • /deployment/kubernetes-ingress/#using-parameters-for-deployment-configuration
  • /deployment/kubernetes/aks/#add-automatic-https-with-cert-manager
  • /deployment/kubernetes/aks/#tell-the-gateway-about-your-hostname

The displayed examples now use methods such as:

withIngressPath(...)
withIngressTlsAuto(...)
withIngressHostnameParam(...)
withGatewayPathRoute(...)
withGatewayTlsIssuer(...)
withGatewayHostnameParam(...)

Nearby explanations continue to describe WithPath, WithRoute, WithTls, and parameter “overloads.” The adjacent HSTS customization example still shows:

await storefront.withTls(letsencrypt, {
    hsts: { includeSubDomains: true, preload: true },
});

Issue: A TypeScript reader is not explicitly taught how these names correspond or how to extend the issuer example with options.

Suggestion: Add TypeScript-specific mapping and an executable customization example. No invalid signature is asserted here, because semantic validation was blocked.

Warning 3: Lightweight dev mode has unrelated live-status errors

On the accepted server:

404 http://localhost:4322/api/live/
WebSocket ... /api/live/ws ... closed before ... established
Live API not found (404); live updates disabled until reload.

Both scoped pages remained readable. These are not attributed to the changed snippets.

Passed Checks

  • Both scoped pages rendered successfully on the accepted server.
  • Seven displayed TypeScript blocks were copied into isolated scratch files:
    • Ingress path, hostname inheritance, parameters
    • Gateway path, issuer TLS, HSTS options, hostname parameter
  • All seven copies matched browser text after Windows newline/EOF normalization.
  • All seven passed TypeScript syntax-only transpilation.
  • Both pages’ rendered same-page anchors resolved to existing DOM targets.
  • Visible deployment-page links checked had trailing slashes.
  • Fifteen local browser targets returned HTTP 200: the two scoped pages, Kubernetes overview, prerequisites, first-app, CLI installation, AKS integration, Gateway/Ingress AKS walkthroughs, Helm charts, Kubernetes integration, pipelines, clusters, persistent volumes, and Azure deployment.
  • Displayed guidance explicitly warns about bootstrap certificates, plaintext HTTP, production certificate rate limits, and staging certificate warnings.

Executed Commands and Results

Exact command Result
bun run dev Failed: bun unavailable on PATH
playwright-cli --help Passed
npx --yes bun --version 1.4.4
npx --yes --package=bun -c "bun run dev" First attempt failed: missing astro; restored attempt served this worktree on 4322
npx --yes --package=bun -c "bun install --cwd ./src/frontend --frozen-lockfile" Passed; 848 packages installed
aspire --version Installed 13.4.0 build shown above
dotnet --list-sdks 10.0.114 and 10.0.403 available
node --version v26.13.0
docker version --format '{{.Server.Version}}' Server 29.9.2 responded
aspire new aspire-ts-starter -n aspire-app -o aspire-app --non-interactive --suppress-agent-init Failed preparation: staging package restore
aspire new aspire-ts-starter -n aspire-stable -o aspire-stable --channel stable --version 13.6.4 --non-interactive --suppress-agent-init Failed: CLI/SDK mismatch and unavailable TypeScript generator
aspire new --help / aspire publish --help Passed; help only
playwright-cli -s=phaseb2002 goto http://localhost:4322/deployment/kubernetes-ingress/ Passed
playwright-cli -s=phaseb2002 goto http://localhost:4322/deployment/kubernetes/aks/ Passed
playwright-cli -s=phaseb2002 close Owned browser closed

The syntax check executed:

node -e "const fs=require('fs'),path=require('path'),ts=require('./src/frontend/node_modules/typescript');let failed=0;for(const name of fs.readdirSync('.doc-tester-workspace/phase-b-pr2002').filter(n=>n.endsWith('.mts'))){const code=fs.readFileSync(path.join('.doc-tester-workspace/phase-b-pr2002',name),'utf8');const result=ts.transpileModule(code,{fileName:name,reportDiagnostics:true,compilerOptions:{module:ts.ModuleKind.NodeNext,target:ts.ScriptTarget.ESNext}});const errors=(result.diagnostics||[]).filter(d=>d.category===ts.DiagnosticCategory.Error);console.log(name+': '+(errors.length?'FAIL '+errors.map(d=>ts.flattenDiagnosticMessageText(d.messageText,' ')).join('; '):'PASS syntax-only; no type/model/runtime validation'));failed+=errors.length;}process.exitCode=failed?1:0"

Result: Seven passes, exit 0. This does not verify API availability, argument types, async behavior, or generated manifests.

Knowledge Gaps

What I needed to know: How the TypeScript-specific method names map to the prose’s C#-style overload descriptions, particularly TLS options.

Source of my knowledge: No product implementation knowledge was used to resolve this; the mapping remains unverified.

User impact: Readers extending the examples may not know which TypeScript method to call.

Recommendation: Explain the mapping or provide complete TypeScript variants.

Context-dependent snippets—not new defects

These are AppHost fragments, not standalone programs. They require previously established builder, k8s/aks, service resources, subnets, load balancer, and issuer as applicable. Repeated const storefront declarations represent replacement stages of the walkthrough, not instructions to concatenate every block. Missing surrounding context was not reported as a new API defect.

Recommendations

  1. Rerun semantic/model and nondeploying aspire publish -o aks-artifacts checks with a compatible 13.6+ CLI/runtime.
  2. Clarify TypeScript method naming and TLS-options usage.
  3. Do not interpret this report as verification of routing, certificate issuance, redirects, HSTS, or hostname inheritance.

No cloud authentication, feature registration, Kubernetes deployment, provisioning, or destructive deployment commands were run.

Cleanup

  • Owned browser closed.
  • Owned server stopped; port 4322 had no listening socket afterward.
  • Foreign port 4321 remained untouched.
  • Owned scratch projects and browser evidence files removed.
  • Tracked dev-generated artifacts left for parent cleanup:
    • src\frontend\.starlight-icons\language-map.json
    • src\frontend\.starlight-icons\material-icons.json
    • src\frontend\.starlight-icons\safelist.json
    • src\frontend\.starlight-icons\version.txt
  • Ignored dependency/dev artifacts remain: src\frontend\node_modules, .astro, and .env.local.

Phase B result frozen; no Phase A conclusions incorporated.


The blind tester's surrounding-prose observation is retained as requested, not promoted to a changed-line correctness finding. Link/style observations and dev-only live API errors are not merge findings. This partial report consumes the documentation stage once for this PR, independent of future head SHAs; no automatic rerun is implied.

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.

3 participants