Skip to content

kubectl-ate: create every actor-template in a multi-document manifest - #4102

Open
Peter Pan (panpan0000) wants to merge 3 commits into
agent-substrate:mainfrom
panpan0000:fix-2156-multidoc-actortemplate
Open

Peter Pan (panpan0000) wants to merge 3 commits into
agent-substrate:mainfrom
panpan0000:fix-2156-multidoc-actortemplate

Conversation

@panpan0000

@panpan0000 Peter Pan (panpan0000) commented Nov 23, 2026 •

Copy link
Copy Markdown

kubectl ate create actor-template -f used to parse only the first YAML document and silently drop the rest. It now parses every document and creates each one in order, continuing past failures and reporting them together, the way kubectl handles a multi-document file. The egress- and access-policy manifests keep their single-document contract through the same parser.

Related: #2157, which tracked multi-document support in kubectl ate create actor-template.

AI use:
AI-assisted; I reviewed the diff and ran go test -race ./cmd/kubectl-ate/....

Breaking change:
No. Note: empty YAML documents (a trailing ---, or comments between separators) are now skipped for every manifest, matching kubectl. The egress- and access-policy parsers previously rejected them.

  • Tests pass
  • Docs updated

@panpan0000
Peter Pan (panpan0000) force-pushed the fix-2156-multidoc-actortemplate branch from 324b949 to 258a766 Compare November 23, 2026 13:11
// instance of msg's message type. YAML is a superset of JSON, so one decoder
// parses both. Documents are split on "---" the way kubectl splits them, and
// empty documents are skipped. Parsing is strict: unknown fields are an error.
func manifestMessages(data []byte, msg proto.Message) ([]proto.Message, error) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 question 🟢 – Should this parser live in internal/manifest (here or in a follow-up) so cmd/ate-setup/internal/steps/substrate.go:63 (ActorTemplateFromManifest, which still calls yaml.YAMLToJSON directly and drops trailing documents) and internal/e2e/fixture.go:67 (decodeSubstrateTemplates, which splits on "\n---") share the same implementation? Both already document matching kubectl ate create actor-template.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks! I suggest moving the parser and updating both callers in a follow-up to keep this PR focused.

@moficodes

Copy link
Copy Markdown
Collaborator

Context for reviewers, since #2156 now returns 404:

  • #2156 ("Reject trailing YAML documents in actor-template create manifests") reported that actorTemplateFromManifest passed the full input to yaml.YAMLToJSON, which parsed only the first YAML document and silently dropped trailing documents.
  • In that thread, the preferred direction shifted from rejecting trailing documents to supporting multi-document YAML manifests in kubectl ate create actor-template -f (creating each document and reporting failures together), while keeping egress-policy and access-policy single-document.
  • Closed PR kubectl ate create actor-template creates every document in a manifest #2157 previously worked on this and still has the earlier review discussion on output shape under partial failure, JSON vs. YAML multi-document wording, and parser test cases.

Please update the PR description to drop the dead Fixes #2156 link (or point it at a new issue).

actorTemplateFromManifest parsed only the first document and silently
dropped the rest. Parse all documents and create each one in order,
continuing past failures and reporting them together, the way kubectl
handles a multi-document file. The egress- and access-policy manifests
keep their single-document contract through the same parser.

Signed-off-by: Peter Pan <Peter.Pan@daocloud.io>
@panpan0000
Peter Pan (panpan0000) force-pushed the fix-2156-multidoc-actortemplate branch from 258a766 to 0933121 Compare November 26, 2026 13:12
@panpan0000

Peter Pan (panpan0000) commented Nov 26, 2026 •

Copy link
Copy Markdown
Author

Pushed 5847642 with fixes and tests for the output schema, errors, manifest wording, and parsing.

I kept the parser in kubectl for now. Moving it and updating ate-setup and the e2e fixture can be a follow-up.

Empty YAML documents are now skipped for all three manifest types; egress and access policies still reject multiple non-empty documents.

Name the document in parse and create errors, keep the -o yaml/-o json schema
stable when only some documents are created, and say that only YAML is a
multi-document format. The parser and the runner are now covered by table
tests, including both JSON objects without a separator, an unknown field in a
second document, top-level sequences, YAML aliases, and a partial create.

The parser stays in cmd/kubectl-ate/internal/cmd for now; sharing it with
ate-setup and the e2e fixture is a follow-up.

Signed-off-by: Peter Pan <Peter.Pan@daocloud.io>
@panpan0000
Peter Pan (panpan0000) force-pushed the fix-2156-multidoc-actortemplate branch from 0933121 to 5847642 Compare November 26, 2026 13:16
Signed-off-by: Peter Pan <Peter.Pan@daocloud.io>
@moficodes

Copy link
Copy Markdown
Collaborator

The PR description still has Fixes #2156, which returns 404 and will not link to or close an issue. Please remove that line (or replace it with a link to a new issue / reference to #2157).

wantIndexes: []int{1},
},
{
name: "block-style YAML documents",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 nit 🟢 – This case uses flow-style mappings (metadata: {name: one}). Change the input to indented block style (metadata:\n name: one\n---\nmetadata:\n name: two\n) so it matches the test name, and optionally keep flow-style YAML as its own case.

fail: map[string]error{"": status.Error(codes.InvalidArgument, "metadata is required")},
wantCalls: []string{"one", ""},
wantErrs: []string{"document 2: failed to create actor template: rpc error", "metadata is required"},
// The empty metadata rendered as "/:" before the document was named.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 nit 🟢 – Drop this comment referencing the earlier revision of the PR. Per AGENTS.md, comments should describe the final state of the code (for example, that missing metadata must not produce an empty atespace/name prefix).

This branch has not been deployed

No deployments
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