Skip to content

sandbox apply: print the decoded sandbox, YAML 1.1-safe, under --dry-run (into #373) - #374

Merged
joehorsnell merged 4 commits into
davido/ENG-1187/hide-dry-runfrom
davido/ENG-1187/dry-run-typed-spec
Sep 25, 2026
Merged

joehorsnell merged 4 commits into
davido/ENG-1187/hide-dry-runfrom
davido/ENG-1187/dry-run-typed-spec

Conversation

@davixcky

@davixcky davixcky commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Stacked: #362 ← #373 (hide the flag) ← this one. Two changes to what --dry-run=client prints.

1. Print the decoded sandbox, not the document as read

--dry-run=client now prints the sandbox as decoded into models.Sandbox, which is exactly what an apply sends. Before, it printed the substituted document as it was read.

  • Removes wholeNumbers. Numbers come from the typed model, so they're already the right type. The model goes back through JSON with UseNumber, and integers are restored as integers.
  • Drops the nulls the generated models emit for unset lists (forks, local, endpoints, …).
  • Anything the decoder would drop or reject can't appear in the output.

(The first commit, d594cd2, accidentally carried only its test. 14d21ba is the apply.go change it was meant to include.)

2. Quote YAML 1.1 lookalikes, a bug in #362

-f reads YAML 1.1 (sigs.k8s.io/yaml), but --dry-run printed through goccy, a YAML 1.2 printer that leaves yes, on, No, y, OFF and 1e3 unquoted:

$ signadot sandbox apply -f s.yaml --dry-run=client > r.yaml   # env DEBUG='yes'
$ grep value r.yaml
        value: yes
$ signadot sandbox apply -f r.yaml --dry-run=client
Error: couldn't parse YAML sandbox definition - cannot unmarshal bool into Go struct field SandboxEnvVar.forks.customizations.env.value of type string

The sandbox Action applies exactly those bytes. So env: DEBUG=yes, a label value like preview=yes, or description: No failed the apply after validation had passed, and a dry-run: true job published a rendered-spec that couldn't be applied. Found by the Action's correctness audit. The dry-run YAML is now printed with sigs.k8s.io/yaml, the same library -f reads with. --dry-run never had a -o yaml format of its own, so no other command is affected.

Evidence

  • Output is byte-identical to sandbox apply: --dry-run to render a spec without applying it #362 on all 8 sandbox-action golden fixtures and on its e2e template with real bindings. Multiline strings still print as | blocks.
  • New tests:
    • TestDryRunPrintsOnlyWhatIsSet
    • TestDryRunQuotesYAML11Lookalikes: yes, on, No, 1e3, 1_000, y and OFF come out quoted, and rendering the output again reproduces it exactly.

Not fixed here: @{ in a rendered value

$ signadot sandbox apply -f t.yaml --dry-run=client --set 'd=build @{sha} ok'
  description: build @{sha} ok
$ signadot sandbox apply -f rendered.yaml --dry-run=client
Error: unexpanded variable: sha

The template language has no escape for a literal @{, and the sandbox Action renders the document more than once. So any value that contains @{ after the first render breaks the next one: a PR title, an @{embed: file} whose file has @{ in it (for example Spring's server.url=@{/login}), or an env value. Options, to decide separately:

  1. Add an escape to the template language (for example @@{ → literal @{) and escape strings in dry-run output.
  2. A hidden flag that skips substitution for a document that's already rendered. The Action's later passes would use it.

🤖 Generated with Claude Code

--dry-run printed the document as read, after substitution. That made
the output depend on how the file spelled things, and needed
wholeNumbers to undo the YAML reader turning every integer into a
float. Print the request as decoded into the API model instead, which is
exactly what an apply sends: numbers keep their types, and nothing the
decoder would drop can appear. The output is unchanged on every fixture
the sandbox Action uses.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Risk: low. Approved. Cursor Bugbot and Cursor Security Agent were not running after the first poll, so those signals were skipped; this is a narrow test-only change with no findings requiring human review. No reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver

davixcky and others added 2 commits September 24, 2026 14:24
The previous commit carried only its test: the change to apply.go was
left out of it. This is that change.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
-f reads YAML 1.1, where an unquoted yes, on, No, y or 1e3 is a bool or
a number, but --dry-run printed through a YAML 1.2 printer that leaves
those strings unquoted. A spec with env DEBUG=yes rendered to
'value: yes', and passing that back to -f failed with 'cannot unmarshal
bool into ... env.value of type string'. The sandbox Action applies
exactly those bytes, so every such value failed the apply after
validation had passed. Print with sigs.k8s.io/yaml, the library -f reads
with. Output is unchanged on every fixture the Action uses.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@davixcky davixcky changed the title sandbox apply: print the decoded sandbox under --dry-run (into #373) sandbox apply: print the decoded sandbox, YAML 1.1-safe, under --dry-run (into #373) Sep 24, 2026
…rt as strings (into #374) (#375)

Stacked: #362 ← #373 ← #374 ← this one.

## Why

The template language has no escape for a literal `@{`. So a spec that
`--dry-run` has rendered can't always be rendered again:

```console
$ signadot sandbox apply -f t.yaml --dry-run=client --set 'd=build @{sha} ok' > r.yaml
$ signadot sandbox apply -f r.yaml --dry-run=client
Error: unexpanded variable: sha
```

The sandbox Action renders once, then validates and applies the result.
So any value containing `@{` after the first render failed the step: a
PR title in `description`, an `@{embed: file}` of a Spring config
(`server.url=@{/login}`), or an env value. The Action's correctness
audit rated this high.

## What

- New hidden bool flag `--no-template`: `-f` is decoded as a finished
spec, with no `@{…}` substitution.
- `--set` together with `--no-template` is refused, because there's
nothing to bind.
- Hidden like `--dry-run`, for the same reason: the Action is the only
caller that needs it while the interface settles.

## Also: labels and resource params called `port`

`port2Int` turned every string under a key named `port` into a number,
including inside `spec.labels` and `resources[].params`, whose keys are
the user's own names. So a label or a param called `port` was refused
with `cannot unmarshal number into … params of type string`. It now
skips those two maps, and endpoint ports still convert as before
(`TestPortKeysInFreeFormMapsStayStrings`). Found by the sandbox Action's
re-audit.

## Tests

- `TestNoTemplateReadsARenderedSpecAsItIs`: a value containing `@{sha}`
and `@{embed: x}` renders once, fails to render a second time without
the flag, and with the flag produces byte-identical output.
- `TestNoTemplateRefusesSet`
- `TestNoTemplateIsHidden`

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
@joehorsnell
joehorsnell merged commit ebf9ccd into davido/ENG-1187/hide-dry-run Sep 25, 2026
1 check passed
@joehorsnell
joehorsnell deleted the davido/ENG-1187/dry-run-typed-spec branch September 25, 2026 17:46
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