Skip to content

fix: stream plugin RPC stdout live and preserve Traefik templates#63

Merged
joecorall merged 1 commit into
mainfrom
fix/rpc-live-stdout-and-traefik-template-quoting
Jun 9, 2026
Merged

fix: stream plugin RPC stdout live and preserve Traefik templates#63
joecorall merged 1 commit into
mainfrom
fix/rpc-live-stdout-and-traefik-template-quoting

Conversation

@joecorall

Copy link
Copy Markdown
Member

This addresses two unrelated paper cuts in the plugin RPC path and the Traefik bot-mitigation config rewriter.

Live plugin stdout

Plugin RPC reserves process stdout for the JSON response envelope, so long-running commands like sitectl create produced no visible progress until the plugin exited. This adds an opt-in LiveStdout execution option (driven by the SITECTL_RPC_LIVE_STDOUT=1 env var) that mirrors command stdout to the plugin process stderr while still capturing it into RPCResponse.Output. The host enables it for create so progress streams live; the buffered output is then suppressed to avoid duplicate printing.

  • cmd/create.go: enable LiveStdout and skip re-printing captured output
  • pkg/plugin/sdk.go: add CommandExecOptions.LiveStdout, plumb the env var, and route the plugin stderr sink when either live flag is set
  • pkg/plugin/rpc_command.go: mirror command stdout to stderr in the plugin when SITECTL_RPC_LIVE_STDOUT=1

Traefik template-safe YAML rewrite

The bot-mitigation rewriter loaded the router config through a YAML parser to inject middleware. Traefik router files embed Go template scalars such as {{ env "DOMAIN" }}, which are not valid bare YAML and broke the load. This quotes unquoted {{ ... }} scalar values before parsing and leaves already-quoted values untouched, so the templates survive the round-trip.

  • pkg/services/traefik/bot_mitigation.go: add quoteTraefikTemplateScalars / singleQuoteYAMLScalar and run them before LoadYAMLDocument

@joecorall joecorall force-pushed the fix/rpc-live-stdout-and-traefik-template-quoting branch from eea16ad to 0fc21e4 Compare June 9, 2026 12:29
This addresses two unrelated paper cuts in the plugin RPC path and the
Traefik bot-mitigation config rewriter.

Plugin RPC reserves process stdout for the JSON response envelope, so
long-running commands like `sitectl create` produced no visible progress
until the plugin exited. This adds an opt-in `LiveStdout` execution option
(driven by the `SITECTL_RPC_LIVE_STDOUT=1` env var) that mirrors command
stdout to the plugin process stderr while still capturing it into
`RPCResponse.Output`. The host enables it for `create` so progress streams
live; the buffered output is then suppressed to avoid duplicate printing.

- `cmd/create.go`: enable LiveStdout and skip re-printing captured output
- `pkg/plugin/sdk.go`: add `CommandExecOptions.LiveStdout`, plumb the env
  var, and route the plugin stderr sink when either live flag is set
- `pkg/plugin/rpc_command.go`: mirror command stdout to stderr in the
  plugin when `SITECTL_RPC_LIVE_STDOUT=1`

The bot-mitigation rewriter loaded the router config through a YAML parser
to inject middleware. Traefik router files embed Go template scalars such
as `{{ env "DOMAIN" }}`, which are not valid bare YAML and broke the load.
This quotes unquoted `{{ ... }}` scalar values before parsing and leaves
already-quoted values untouched, so the templates survive the round-trip.

- `pkg/services/traefik/bot_mitigation.go`: add `quoteTraefikTemplateScalars`
  / `singleQuoteYAMLScalar` and run them before `LoadYAMLDocument`
@joecorall joecorall force-pushed the fix/rpc-live-stdout-and-traefik-template-quoting branch from 0fc21e4 to 20e60a6 Compare June 9, 2026 12:37
@joecorall joecorall merged commit c9830d2 into main Jun 9, 2026
1 check passed
@joecorall joecorall deleted the fix/rpc-live-stdout-and-traefik-template-quoting branch June 9, 2026 12:48
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.

1 participant