Skip to content

cli: merge root and subcommand --rpc-plugins values, and add the flag to dry-run - #4976

Merged
Leward merged 1 commit into
mainfrom
pj/rpc-plugins-lineage
Oct 20, 2026
Merged

Leward merged 1 commit into
mainfrom
pj/rpc-plugins-lineage

Conversation

@Leward

@Leward Leward commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Important

This PR must be in the same Connect release as the benthos bump that brings in redpanda-data/benthos#531, or in an earlier one.
Without it, connect --rpc-plugins P lint and connect --rpc-plugins P test stop loading the plugin.
This PR does not depend on redpanda-data/benthos#531, so it can merge first.

Summary

--rpc-plugins is defined on the root app and on run (and on lint and test after redpanda-data/benthos#531). urfave/cli v2 c.StringSlice returns the value from the first flag set in the lineage that defines the flag, also when it is not set there. Thus the root value is lost when the subcommand also defines the flag. dry-run did not register RPC plugins at all.

 extract (run, streams, lint, test, ...)
-  DiscoverAndRegisterPlugins(c.StringSlice("rpc-plugins"))
+  DiscoverAndRegisterPlugins(rpcPluginPaths(c))

 dry-run
+  flags += rpc-plugins
+  DiscoverAndRegisterPlugins(rpcPluginPaths(c))
   for each target: dry run

+rpcPluginPaths(c)
+  for each context in c.Lineage() where the flag is set locally
+    collect its values

The Python plugin README now shows rpk connect dry-run --rpc-plugins=plugin.yaml connect.yaml for CI checks.
lint --rpc-plugins is not documented yet. Add it when redpanda-data/benthos#531 is in a Connect release.

Evidence

Unit tests.

  • TestRPCPluginPaths: table over root only, command only, both, none.
    • Before: fails for all cases that set a path.
    • After: passes.

End-to-end. The same checks as redpanda-data/benthos#531, plus dry-run, with the catshout test plugin. Four builds: Connect main (bcdefa4) and this branch, each against benthos v4.83.0 and against redpanda-data/benthos#531 (dd2d9b5).

Command main + v4.83.0 main + #531 this PR + v4.83.0 this PR + #531
connect lint --rpc-plugins P cfg.yaml ❌ flag provided but not defined ✅ ❌ flag provided but not defined ✅
connect --rpc-plugins P lint cfg.yaml ✅ ❌ unable to infer processor type ✅ ✅
connect test --rpc-plugins P cfg.yaml ❌ flag provided but not defined ✅ ❌ flag provided but not defined ✅
connect --rpc-plugins P test cfg.yaml ✅ ❌ unable to infer processor type ✅ ✅
connect run --rpc-plugins P cfg.yaml ✅ ✅ ✅ ✅
connect --rpc-plugins P run cfg.yaml ❌ unable to infer processor type ❌ unable to infer processor type ✅ ✅
connect dry-run --rpc-plugins P cfg.yaml ❌ flag provided but not defined ❌ flag provided but not defined ✅ ✅
connect --rpc-plugins P dry-run cfg.yaml ❌ unable to infer processor type ❌ unable to infer processor type ✅ ✅

run prints MEOW! MEOW! and test prints succeeded where they pass.

Merge Danger

Door: two-way

Blast Radius: CLI

  • If the flag is set at two levels, both value lists now load. Before, only the subcommand value loaded.
  • A duplicate path registers twice. The second registration replaces the first one with the same plugin. If two manifests declare the same plugin name, the root one wins (it registers last).
  • This PR fixes --rpc-plugins only. The other custom flags (--secrets, --redpanda-license, --chroot, telemetry) still read the subcommand value only. With cli: declare custom run flags on the lint and test subcommands benthos#531 that also applies to lint and test.

Ref: ENG-1270

Comment thread internal/cli/dry_run.go
return err
}

if err := rpcplugin.DiscoverAndRegisterPlugins(service.OSFS(), schema.Environment(), rpcPluginPaths(c)); err != nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The new dry-run plugin registration has no test in this PR. The description says TestDryRunRPCPlugins covers the flag before and after dry-run, but the test is not in the diff, and no file in the repo defines it. TestRPCPluginPaths only tests the helper on a fake app. It does not check that dry-run defines the flag or registers plugins before it parses the targets.

Please commit the TestDryRunRPCPlugins test the description mentions (skipped in CI like internal/rpcplugin/processor_test.go), or add a test that fails without these lines. The project test patterns say to "Flag changed code lacking tests".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There was a test but its evidence was weak and has therefore been removed.

… to dry-run

The rpc-plugins flag is defined on the root app and on run. urfave/cli
reads the value from the subcommand context, so the root value was
ignored for `connect --rpc-plugins P run`. Add rpcPluginPaths, which
collects the values from each level where the flag is set. The paths are
not sorted or deduplicated: a second registration of a plugin name
replaces the first one, so the root manifest wins over the subcommand
manifest.

The dry-run command did not register RPC plugins. Add the flag to
dry-run and register the plugins before the targets are checked.

Ref: ENG-1270
@Leward Leward changed the title cli: read --rpc-plugins at every command level and in dry-run cli: merge root and subcommand --rpc-plugins values, and add the flag to dry-run Oct 19, 2026
@Leward
Leward force-pushed the pj/rpc-plugins-lineage branch from 387b052 to 191f6af Compare October 19, 2026 18:03
@Leward
Leward merged commit 9964fdb into main Oct 20, 2026
13 of 16 checks passed
@Leward
Leward deleted the pj/rpc-plugins-lineage branch October 20, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants