Skip to content

feat(lifecycle): add plugin.settings.test and settings_schema.test - #3

Merged
0xJacky merged 4 commits into
mainfrom
feat/settings-test-hook
Dec 5, 2026
Merged

0xJacky merged 4 commits into
mainfrom
feat/settings-test-hook

Conversation

@0xJacky

@0xJacky 0xJacky commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

Adds the contract for a settings "test connection" hook, as implemented in nginx-ui draft 0xJacky/nginx-ui#2188.

What it adds

  • lifecycle.proto: rpc SettingsTest with rpc_name = "plugin.settings.test", plus PluginSettingsTestRequest { Struct settings } and PluginSettingsTestResponse { bool ok; string message }. The host sends it only to a plugin whose manifest declares settings_schema.test. A plugin may also answer -32003 with data.field.
  • manifest.proto and plugin.schema.json:
    • settings_schema.test (SettingsTest { int32 timeout_seconds }, 0 to 60, where 0 or absent means 15). If it is there, the plugin serves the hook.
    • settings[].bound_to (list of setting keys, for secret fields). During a test the host passes a stored secret to the plugin only while every field it is bound to still has its saved value; absent means it is bound to every other field. On save, the host keeps a stored secret only while every field bound_to lists keeps its saved value, otherwise it refuses the save and the person enters the secret again; absent leaves saving unrestricted. A newly entered secret is always accepted. The proto comments of bound_to, PluginSettingsTestRequest and PluginConfigureRequest and the schema description say so.
  • gen/: regenerated with make generate (pinned buf 1.73.0, protoc-gen-go 1.36.12, protoc-gen-go-grpc 1.6.2). gen/methods.json gains plugin.settings.test.
  • Vectors 53-plugin-settings-test-valid.json and 54-plugin-settings-test-invalid-config.json.

The change is additive and api_version stays 1. Older hosts ignore the new manifest members, and the schema used to reject test and bound_to. A host that implements this refuses a save that changes a field listed in bound_to while keeping the stored secret (maintainer decision on nginx-ui #2188); plugins that declare no bound_to save as before.

Landing order

  1. This PR (plugin-spec) goes first.
  2. Then the SDKs: feat: serve plugin.settings.test through Plugin.TestSettings plugin-sdk-go#1 (Plugin.TestSettings) and feat: type settings tests and the settings panel props plugin-sdk-web#3 (SettingsTestResult, SettingsPanelProps).
  3. Then nginx-ui #2188.

This branch is rebased onto main, which carries HostSite.server_names from #4. nginx-ui and plugin-sdk-go keep verbatim copies of gen/go/nginxui/plugin/v1. Their PRs copy this branch's output byte for byte, including the author field from #2 that neither had synced yet, and in plugin-sdk-go also server_names.

Checks

make check passes locally: buf lint and format, the generated code and methods.json are current, and the tests of both Go modules pass.

🤖 Generated with Claude Code

0xJacky added a commit to 0xJacky/nginx-ui that referenced this pull request Dec 5, 2026
Copy gen/go of nginxui/plugin-spec#3 verbatim. Spec main also carries
the informational Manifest.author (nginxui/plugin-spec#2), so mirror it in
protocol.Manifest to keep the alignment test green.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0xJacky and others added 2 commits December 5, 2026 23:40
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A secret that lists bound_to is now kept on save only while the listed
settings keep their saved values. Without bound_to saving is unchanged,
while a settings test still binds the secret to every other setting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@0xJacky
0xJacky force-pushed the feat/settings-test-hook branch from fbc35e5 to 29f2635 Compare December 5, 2026 15:59
0xJacky added a commit to nginxui/plugin-sdk-go that referenced this pull request Dec 5, 2026
Copy gen/go of nginxui/plugin-spec#3 rebased onto main. It brings
HostSite.server_names from plugin-spec#4, so protocol.HostSite gains
ServerNames, and the bound_to comments now describe that a save keeps a
stored secret only while the settings its bound_to lists are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0xJacky added a commit to 0xJacky/nginx-ui that referenced this pull request Dec 5, 2026
Copy gen/go of nginxui/plugin-spec#3 verbatim. Spec main also carries
the informational Manifest.author (nginxui/plugin-spec#2), so mirror it in
protocol.Manifest to keep the alignment test green.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0xJacky added a commit to 0xJacky/nginx-ui that referenced this pull request Dec 5, 2026
A save that keeps a stored secret, by the placeholder or a missing key,
is refused with 55034 while a setting the secret's bound_to lists differs
from its saved value (after defaults). A typed secret is always accepted
and never compared with the stored one. Secrets without bound_to save as
before; a settings test still binds them to every other setting.

The generated settings form shows the refusal on the secret field and
asks for the secret again. The pb copy is synced with nginxui/plugin-spec#3
rebased onto main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0xJacky and others added 2 commits December 6, 2026 00:12
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ently

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0xJacky added a commit to 0xJacky/nginx-ui that referenced this pull request Dec 5, 2026
Also sync the pb copy with nginxui/plugin-spec#3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@0xJacky
0xJacky merged commit ab8073d into main Dec 5, 2026
1 check passed
0xJacky added a commit to nginxui/plugin-sdk-go that referenced this pull request Dec 5, 2026
* feat: serve plugin.settings.test through Plugin.TestSettings

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore: sync the manifest author from plugin-spec

plugin-spec added an informational author (Manifest.author = 34) in
nginxui/plugin-spec#2. Copy the regenerated pb/manifest.pb.go and mirror
the field in protocol.Manifest so pb/ stays a verbatim copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore: sync pb with plugin-spec and document the save binding

Copy gen/go of nginxui/plugin-spec#3 rebased onto main. It brings
HostSite.server_names from plugin-spec#4, so protocol.HostSite gains
ServerNames, and the bound_to comments now describe that a save keeps a
stored secret only while the settings its bound_to lists are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore: sync pb with plugin-spec

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore: sync pb with plugin-spec

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
0xJacky added a commit to 0xJacky/nginx-ui that referenced this pull request Dec 5, 2026
…#2188)

* feat(plugin): let the host test candidate plugin settings

A settings panel only ever holds the redaction placeholder of a stored
secret, so it cannot test a connection itself. Add an opt-in host hook:
POST /api/plugins/:id/settings/test runs behind the same secure session and
demo guards as saving, merges the stored secrets into the candidate
settings and calls plugin.settings.test on the plugin that declares
settings_schema.test. The candidate is never stored or returned; the
answer is a bounded { ok, message, field } scrubbed of the secret values.

A stored secret is merged only while every setting it is bound to keeps its
saved value (bound_to, every other setting by default), so a test cannot
pair a stored secret with a new destination. Saving is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(plugin): keep the settings test slot until the plugin call ends

The plugin is never told that a call was abandoned, so a caller who aborts
and retries must not free the one-test-per-plugin slot early. Run the call
detached from the request with the test timeout, correct the documented
timeout range and cover more binding cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore(plugin): sync the contract with nginxui/plugin-spec#3

Copy gen/go of nginxui/plugin-spec#3 verbatim. Spec main also carries
the informational Manifest.author (nginxui/plugin-spec#2), so mirror it in
protocol.Manifest to keep the alignment test green.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(plugin): translate the settings test into zh_CN and zh_TW

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(plugin): enforce bound_to on save for secrets that declare it

A save that keeps a stored secret, by the placeholder or a missing key,
is refused with 55034 while a setting the secret's bound_to lists differs
from its saved value (after defaults). A typed secret is always accepted
and never compared with the stored one. Secrets without bound_to save as
before; a settings test still binds them to every other setting.

The generated settings form shows the refusal on the secret field and
asks for the secret again. The pb copy is synced with nginxui/plugin-spec#3
rebased onto main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(plugin): test the default fallback of the save binding

A bound field without a stored value counts as its schema default; add
tests for it and correct the comments and docs that called an empty
value a fall back to the default. Document the cluster sync case and
the one-secret-at-a-time refusal, and pin the save route status.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(plugin): call a secret setting 机密/機密 in the settings test docs

Follow the term the zh_CN and zh_TW plugin docs use for a secret setting,
where 密钥/金鑰 means a cryptographic key, make the links repeat the
heading, and state the empty-secret and cluster sync cases precisely.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(plugin): call the plugin HTTP endpoint 介面 in zh_TW

Also sync the pb copy with nginxui/plugin-spec#3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@0xJacky
0xJacky deleted the feat/settings-test-hook branch December 5, 2026 17:03
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