Skip to content

fix(install): materialize the template's file set and its .env.example defaults (12, 33) - #365

Merged
vsilent merged 43 commits into
all-fixesfrom
fix/install-file-set-12-33
Nov 20, 2026
Merged

vsilent merged 43 commits into
all-fixesfrom
fix/install-file-set-12-33

Conversation

@vsilent

@vsilent vsilent commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

What

BUGS.md #12 and #33 — one root, one fix: stacker install <template> wrote only stacker.yml. A template whose file set ships scripts/ and .env.example therefore installed into a project that could not deploy:

How

Both options the entries ask for:

  • install materializes the template's file set from latest_version.config_files next to stacker.yml (scripts/, config files) and seeds .env from .env.example when .env does not exist — existing files are never overwritten (user deployments/logs  #33 + Issue 2 #12)
  • the ${VAR} resolver treats .env.example as defaults under the env file, so a template default is honoured even when install never wrote .env; the env file overrides it (Issue 2 #12's second option)

Tests

Red→green: materialization writes scripts/… and seeds .env, refuses to overwrite anything; the resolver fills placeholders from .env.example with the env file winning. Full suite green except the pre-existing flaky tests/agent_sweep.rs.

Verify

In BUGS.md #12 and #33 ("How to verify"): install the n8n template into an empty directory — the referenced files must exist and the FLOWISE_USERNAME-class placeholder must resolve.

robotizeit and others added 30 commits November 17, 2026 18:07
…e (55)

One project can hold several deployment locks (one per target) and the
agent commands read the first of a fixed cloud->server->local order — the
inactive target's, days-older deployment — while `stacker target` named
the live one. `--deployment` papered over it, `deployment state` resolved
through a different rule, and nothing said what was resolved.

In the order the entry asks for:

- every implicit resolution prints one line — `resolved deployment <hash>
  (from .stacker/deployment-server.lock, target: server)` — and warns when
  a newer lock exists than the one chosen
- resolution order is explicit `--deployment`, the pinned
  `deploy.deployment_hash`, the preferred/active target's lock, then the
  newest — never a fixed target order (DeploymentLock::rank_locks; local
  locks cannot shadow a remote one)
- `stacker deployment use <hash>|--clear` pins/unpins the deployment this
  directory works with, so holding one is an act, not a side effect
- the deployment hash is recorded in the lock at deploy time (and the
  handoff payload carries it) — humans reading the file can pass it to
  `--deployment` without an API lookup
- `stacker explain topology` takes `--deployment` and resolves through the
  shared chain instead of printing `for unbound`

Co-Authored-By: Claude Opus 5 <[email protected]>
Every `push` run of Docker CICD is green and both `pull_request` runs failed,
at the same place:

    #9 exporting to image ... pushing layers 1.1s done
    #10 ERROR: failed to reserve cache: cache write denied: token has no writable scopes
    #9 CANCELED
    ERROR: failed to build: failed to solve: failed to reserve cache

The image was already pushed when the cache export was refused, and the
refusal cancelled the step and failed the job. Two changes, one for each half
of that:

- `permissions: contents: read, actions: write` on both workflows that use the
  GitHub Actions cache. It writes through GITHUB_TOKEN, and neither workflow
  declared permissions at all, so each inherited whatever the default is -
  which on these pull_request runs has no writable scope. Both only use
  checkout, setup-node, the docker actions and artifacts, so the explicit
  block takes nothing away.
- `ignore-error=true` on both `cache-to: type=gha` exporters. A cache is an
  optimisation; losing it is not a reason to fail a build. `ignore-error` is a
  documented cache-to option.

Not changed, and worth a decision rather than a quiet edit: the stackerdb job
runs with `push: true` on `pull_request`, so every pull request publishes
`trydirect/stackerdb:latest` to Docker Hub - the failed run above had already
pushed the layers before the cache error stopped it.

Co-Authored-By: Claude Opus 5 <[email protected]>
fix(ci): a cache export must not fail a build that already pushed
The released binary reports its own version, so the bump goes in before the
tag. 0.3.10 carries the deployment-resolution fix (#55): agent commands now
resolve the active target's lock instead of whichever one came first, print
the deployment they resolved and where it came from, warn when a newer lock
exists, and `stacker deployment use <hash>` pins one deliberately.

Co-Authored-By: Claude Opus 5 <[email protected]>
One page from install to teardown: starting a project, secrets, running it
locally, deploying to a server, picking which deployment you are talking to,
watching it without SSH, shipping a new version, proxy and firewall,
marketplace, pipes and CI.

Built from the CLI rather than from memory - the command list and the flags
come from `--help` and the argument definitions, and a check confirms that all
38 top-level commands named on the page exist. Where a command bites, the page
says so inline and points at the BUGS.md entry: the missing `env_file` after
`service add` (#47), no remote target building images while `--dry-run` passes
anyway (#48), the hardcoded `server.js` (#49), `status` resolving the wrong
project (#20, #25), the reported compose path (#53), what `sync` does not do
(#54), and the deployment resolution rules (#55).

Also documents what 0.3.10 added: the resolution line, the warning about a
newer lock, and `stacker deployment use`.

Co-Authored-By: Claude Opus 5 <[email protected]>
…t's (25)

`stacker status` resolved through `find_project_by_name` — and the deploy
renames the project to the stacker.yml `name`, so a namesake project on the
account answered with ITS months-old deployment, on a decommissioned server,
while the deploy that just ran looked green. Nothing on screen said the
report was about another deployment.

Per the entry's fix direction: local evidence now wins — the pinned
`deploy.deployment_hash`, then this directory's deployment lock (recorded
hash, or the deployment id for locks older than #55) — with the 55-style
`resolved deployment <hash> (from .stacker/deployment-server.lock, target:
server)` line. The project-name lookup is the last resort, and when it
reports a deployment the lock disagrees with, a warning names both ids and
the pinning commands.

Co-Authored-By: Claude Opus 5 <[email protected]>
…t (20)

Every redeploy onto a host the stack already ran on risked ending
`paused [port_conflict]` while the stack was healthy and serving — the port
checks could not tell the stack's own containers from a real conflict. The
pipeline side is fixed in tfa (PRs #149/#150); this closes the CLI's remote
pre-flight, which SSHed `ss`+`docker ps` and flagged the stack's own
published ports as occupied before `docker compose up` would have replaced
those very containers.

The pre-check now asks for two sections — host listeners with their process,
and containers with their `my.stacker.service` label (the shipped compose
marks every container; the same lookup tfa PR #150 uses live) — and
classifies conflicts in Rust: a docker-proxy listener defers to the container
section, containers labelled with this compose file's own service names are
replaceable, anything else is still a conflict.

Tests: the live 2026-11-13 shape (own `project-n8n-1` holding 5678) is not a
conflict; foreign containers and host processes still are; netstat-style
listeners parse.

Live verification remains before BUGS.md #20 closes (per tfa #150): a
redeploy of a running stack with unchanged ports must end `completed`.

Co-Authored-By: Claude Opus 5 <[email protected]>
…rver.js (49)

`stacker init --app-type node` (and every later Dockerfile generation) wrote
CMD ["node", "server.js"] regardless of the project's own package.json, so
any project whose entry point is the npm default index.js crash-looped with
MODULE_NOT_FOUND. The generator already read the manifest to detect node.

Per the entry's expected outcome: CMD is ["npm", "start"] when
scripts.start exists, else node <package.json main>, else server.js as the
last resort (and the hardcoded form survives only when the manifest is
unreadable). Next.js keeps its build-then-start flow.

Tests: start-script, main-only and no-clues cases; the test that pinned the
buggy fallback is rewritten. Docs: the node Dockerfile example and the
CHEATSHEET 'Trap (#49)' now describe the rule.

Co-Authored-By: Claude Opus 5 <[email protected]>
… path that works (48)

Two defects from the first-run rehearsal:

1. `--dry-run` certified configs the real deploy rejects. The app.image
   requirement ("the Stacker server pulls a pre-built image") fired only in
   the real run, so a build-only app from `stacker init` previewed
   successfully and then refused to deploy to every remote target. It is now
   part of CloudDeploy/ServerDeploy::validate, which the preview runs too —
   a config that cannot deploy fails its preview first.

2. The cloud error told the user to "keep building from source and deploy to
   your own server: `stacker deploy --target server`" — which fails
   identically (no remote target builds from source). It now names
   `--target local` and says plainly that remote targets pull a pre-built
   image.

Tests: strategy validation rejects a build-only app for both remote targets
(red first — it passed them) and accepts an image app; the message test now
expects the working advice.

Co-Authored-By: Claude Opus 5 <[email protected]>
…(29)

Right after a cloud deploy — the very next step the deploy suggests —
`stacker agent install` refused because `deploy.server.host` is empty,
which it is by design for a cloud deploy: the host does not exist until the
deploy makes it. The operator had to copy the address out of the deploy
output and hand-edit stacker.yml, the file the tool generates.

Per the entry's fix direction, the host is resolved from the deployment
lock, the way `agent status` resolves the deployment itself:

- a blank `deploy.server.host` now behaves like "not configured" — the
  server selector falls back to the project's server instead of strict-
  matching an empty string, and the deploy form falls back to the platform's
  server record (as with no deploy.server at all)
- `effective_server_config` fills the host (user/port/key too) from the
  deployment lock for the local-SSH path, ignoring the loopback a local
  deploy leaves behind

Tests: the selector accepts a blank configured host (red first — it
refused), effective_server_config prefers config then lock then nothing.

Co-Authored-By: Claude Opus 5 <[email protected]>
…sh (30)

Established first: nothing refreshes the catalogue from the source
repository — no sync job, cron, DAG, CI step or webhook. The catalogue is a
snapshot of the last manual `stacker publish` and its review, so a fix
merged upstream cannot arrive until someone re-publishes. That contract is
now documented in docs/MARKETPLACE_PUBLISH.md.

And a lagging copy is now visible instead of inferred: every publish records
the git commit of its checkout (`source_commit`, best-effort `git rev-parse
HEAD`) on `stack_template_version` — a new nullable column, set on create,
update and resubmit — and the public detail API returns it at
`item.latest_version.source_commit`. Absent for non-git checkouts and for
versions published before this existed.

Tests: the publish body carries the commit and omits it when unknown, the
git output parser accepts only an object id, and an integration round-trip
(create → approve → GET /api/templates/<slug>) asserts the API surfaces it.

Co-Authored-By: Claude Opus 5 <[email protected]>
… (56)

Two messages, both found by a person following the normal path today.

`stacker status` after a cloud dry-run printed the local containers. That is
correct - a dry run deploys nothing and the only lock is the local one - but
the output is a bare `docker compose ps` with no line saying which placement
it resolved, so it reads as the wrong answer. 0.3.10 gave the agent commands
exactly that line; status never got it.

`stacker target cloud` on a project that has not deployed to cloud refuses
with "No cloud deployment lock found. Deploy to cloud first before switching."
The rule is right, the message stops at the diagnosis, and it is the first
command anyone tries when they want the cloud. The entry proposes the wording,
including the two commands that actually get you there.

Co-Authored-By: Claude Opus 5 <[email protected]>
… (47)

The second command of a fresh walkthrough left the project in a state the
third called invalid: `stacker service add postgres` introduces
\${POSTGRES_PASSWORD}-style references, `stacker secrets set` stores the
values in `.env`, and `stacker config validate` still failed with
"Environment variable not found" — because the placeholder resolver read
only the env_file the config points at, while `secrets set` defaults to
`.env`. The two commands disagreed about where secrets live, and no amount
of setting secrets bridged it.

Per the entry's expected outcome: with no `env_file` named, the resolver
falls back to `.env` — the same default `secrets set` writes to. A
placeholder with no source anywhere still fails.

Tests (red first — the exact repro error): .env fills placeholders when no
env_file is named; an unsourced placeholder still fails. Verified end-to-end
with the CLI: service add → secrets set → config validate passes.

Co-Authored-By: Claude Opus 5 <[email protected]>
fix(deploy): a port held by the stack being deployed is not a conflict (20)
fix(generator): the node CMD follows package.json, not a hardcoded server.js (49)
fix(deploy): dry-run runs the deploy's checks, and its advice names a path that works (48)
fix(agent): agent install resolves the host from the deployment lock (29)
vsilent and others added 13 commits November 20, 2026 09:52
feat(marketplace): record and surface the source commit of each publish (30)
fix(config): placeholders resolve from .env when no env_file is named (47)
…ed file

BUGS.md #27 is implemented by PR 336 (merged 2026-11-13): install writes
its flags into the stacker.yml it generates for server-held templates —
--domain/--set into install.inputs, --key/--key-id/--provider/--region/
--size into deploy.cloud, with a stderr note naming any flag it could not
write. The entry's acceptance line ("a value passed to --domain appears in
the generated file") had no direct test at the file level; this pins it.

Co-Authored-By: Claude Opus 5 <[email protected]>
…s the flavour (37)

One `proxy add` round-tripped the whole stacker.yml through a YAML
serializer: every comment vanished (20 '#' lines down to 6, all of them text
inside a block scalar), quoting was normalised, inline lists expanded, blank
lines removed, escaped regexes lost their quotes. For a template whose
comments are its documentation the command was destructive in practice.

The edit now splices only the top-level `proxy:` block into the file (text
edit, not a round-trip) and leaves every other byte untouched; a missing
block is appended. Regression tests assert byte-identical surroundings —
comments, quoting, inline lists and blank lines — and the append path.

The entry's second half: `--type nginx-proxy-manager|npm|caddy|traefik`
records the flavour instead of silently flipping the config to NPM
(caddy/traefik get their own flow, NPM is configured on deploy). The
'retired' value `nginx` is refused by the flag — the supported set is the
documented one (docs/STACKER_YML_REFERENCE.md).

Co-Authored-By: Claude Opus 5 <[email protected]>
Parallel merges left entry 29's Fixed block under a duplicate entry-30
heading and entry 49 announced twice. Each entry now carries its own block
exactly once.
test(marketplace): pin 27's acceptance — --domain reaches the generated file (27)
…ts-37

fix(proxy): proxy add edits the proxy block in place, and --type names the flavour (37)
…e defaults (12, 33)

`stacker install <template>` wrote only stacker.yml. A template whose file
set ships `scripts/` and `.env.example` therefore installed into a project
that could not deploy: the referenced `./scripts/...` did not exist (empty
directory at best), and every `\${VAR}` whose value is a `.env.example`
default failed with 'Environment variable not found'.

Two halves, as the entries' fix directions ask:

- install materializes `latest_version.config_files` next to stacker.yml
  (scripts/, config files) and seeds `.env` from `.env.example` when `.env`
  does not exist yet; existing files are never overwritten (#33, #12)
- the `.\${VAR}` resolver treats `.env.example` as defaults under the env
  file — the deploy honours a template default even without install's .env
  (#12's second option)

Tests: materialization writes scripts + seeds .env and refuses to overwrite;
the resolver fills placeholders from .env.example with the env file
overriding. Full suite green except the pre-existing flaky
`tests/agent_sweep.rs`.

Co-Authored-By: Claude Opus 5 <[email protected]>
@vsilent
vsilent changed the base branch from dev to all-fixes November 20, 2026 16:51
@gitguardian

gitguardian Bot commented Nov 20, 2026

Copy link
Copy Markdown

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
40550784 Triggered Generic Password ce158b9 src/cli/config_parser.rs View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@vsilent
vsilent merged commit b042d1f into all-fixes Nov 20, 2026
10 of 11 checks passed
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