Skip to content

[release/17.0] Align JavaScript Dockerfile run-script validator with Go and Python pipeline registration - #22006

Closed
Mitch Denny (mitchdenny) wants to merge 1 commit into
mitchdenny-backport-17-0-08-pr21846from
mitchdenny-backport-17-0-09-pr21461
Closed

Mitch Denny (mitchdenny) wants to merge 1 commit into
mitchdenny-backport-17-0-08-pr21846from
mitchdenny-backport-17-0-09-pr21461

Conversation

@mitchdenny

Copy link
Copy Markdown
Member

Description

Backport of #21461 to release/17.0 (cherry-picked from 059be63 with no modifications). Layer 9 of 55 in the release/17.0 backport stack; stacked on #22005.

Backport recommendation: Yes — Fixes spurious publish failures and a crash in the JS Dockerfile validator.

Backport of #21461

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

…ipeline registration (#21461)

## Description

Part of #21205. Aligns the JavaScript existing-Dockerfile run-script
validator (`validate-javascript-dockerfile-run-script-{name}`) with the
Go and Python validators fixed in #21186.

### Bugs on `main`, each reproduced by a new test

1. **Excluded resources still fail publish.** A JavaScript app with an
existing Dockerfile and an explicit run script that is marked
`ExcludeFromManifest()` still runs the validator and throws `JavaScript
app resource 'js' is configured to run script 'migrate', but publish is
using the existing Dockerfile ...`. The resource isn't published at all,
so this failure is spurious.
2. **`PublishAsDockerFile(c => c.WithDockerfile(...))` crashes in
publish mode.** The validator was a second `PipelineStepAnnotation` on
the container. `WithDockerfile` calls
`EnsureBuildAndPushPipelineAnnotations`, which adds its annotation with
`ResourceAnnotationMutationBehavior.Replace` and then fails with
`InvalidOperationException: Sequence contains more than one element`.
3. **Deploy graphs skip the validator.** It was only `RequiredBySteps =
[Build, Publish]`. Azure Container Apps and App Service select a
resource's `BuildCompute` steps directly, so `build-{name}` never
depended on the validator.

### Fix

This is the same shape #21186 merged for Go and Python:
- Register the step through `builder.Pipeline.AddStep`, so it's no
longer a container annotation that `WithDockerfile` can replace.
- Skip validation when
`containerBuilder.Resource.IsExcludedFromPublish()`.
- Make the container's `BuildCompute` steps depend on the validation
step through `WithPipelineConfiguration`.

The existing test
`PublishPipelineWithExistingDockerfileThrowsFromValidationStepWhenRunScriptNameIsExplicit`
built a bare `new DistributedApplicationPipeline()`, which doesn't
contain steps added through `builder.Pipeline`. It now resolves the
app's `IDistributedApplicationPipeline`, as the Go and Python tests in
#21186 do. Its assertions are unchanged.

Not in this PR (remaining #21205 items): the Next.js standalone check's
`BuildCompute` dependency and a shared helper across Go, Python and
JavaScript.

### Before/after (local)

| Test | Before (`main` source) | After |
|---|---|---|
| `PublishPipelineValidationStepIsNoOpForResourceExcludedFromManifest` |
❌ `DistributedApplicationException: JavaScript app resource 'js' is
configured to run script 'migrate' ...` | ✅ |
| `PublishPipelineValidationStepSurvivesLaterWithDockerfile` | ❌
`InvalidOperationException: Sequence contains more than one element`
(from `WithDockerfile`) | ✅ |
| `PublishPipelineRunsValidationStepBeforeImageBuildStep` | ❌
`Assert.Contains() Failure: Filter not matched` (validator not in the
`build-js` closure) | ✅ |

- The four `*PublishPipeline*` tests pass in 20/20 repeated runs.
- Full `Aspire.Hosting.JavaScript.Tests`: 408/427 pass locally. The 19
failures are environmental and unrelated:
- Bun and Deno functional tests fail in 0ms because those tools aren't
installed.
- Verify snapshot tests fail because the sandbox HOME is `/root`, which
the scrubber rewrites inside `/root/.cache`. With a different HOME, all
101 snapshot tests pass.

## Checklist

- Is this feature complete?
  - [ ] Yes. Ready to ship.
  - [x] 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

**🤖 Posted by AspireAgent (AI Agent)**

---------

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: David Pine <david.pine@microsoft.com>
Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
(cherry picked from commit 059be63)
@github-actions

This comment has been minimized.

@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-backport-17-0-09-pr21461 branch 2 times, most recently from a9aa67e to 47b917e Compare November 10, 2026 04:24
@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 -- 22006

Or

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

@mitchdenny
Mitch Denny (mitchdenny) marked this pull request as ready for review November 10, 2026 04:30
@mitchdenny

Copy link
Copy Markdown
Member Author

Approved for inclusion in release/17.0. Do not merge yet.

@github-actions

This comment has been minimized.

@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.

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