Validate Plugin Configuration
Use this guide when you have a plugin kind and need predictable diagnostics before the plugin installs runtime behavior.
What You Build
Define a JSON-compatible component configuration, validate required fields and supported values, return structured diagnostics, and confirm that disabled components still report configuration problems before rollout.
Configuration Shape
The canonical plugin configuration is a top-level document with version, components, and policy.
Each component has:
kind: the plugin kind to activate.enabled: whether the component should initialize.config: the component-local JSON object passed to validation and registration.
Relay validates disabled components. This lets operators detect configuration problems before enabling a component in a later rollout.
The top-level policy controls validation that Relay handles, including unknown
plugin kinds and unsupported document versions. A custom plugin’s validate()
method controls how its own config fields handle unknown fields and
unsupported values.
The following examples create the same configuration in each supported binding:
Python
Node.js
Rust
Validation Rules
Keep validation deterministic and side-effect free. Inspect configuration and return diagnostics. Do not register middleware, open network connections, create clients, or change process state.
Validate these areas first:
- Required fields are present.
- Field types match the supported shape.
- Your plugin reports unknown component-local fields with the diagnostic level its contract defines.
- Your plugin reports unsupported component-local values with the diagnostic level its contract defines.
- Cross-field combinations make sense.
- Sensitive values are references or secret names, not raw credentials.
Use warnings when a config can still activate but deserves operator attention. Use errors when initialization should not proceed.
Diagnostic Shape
Diagnostics should be actionable and stable enough for tests or deployment automation:
Prefer stable diagnostic codes over prose-only messages. The message can improve over time; the code should remain testable.
Validate Before Initialization
Use the validation API before initialization and fail deployment if the report contains errors.
This error check does not catch an enabled unknown or unregistered component
kind. Under the default unknown_component="warn" policy that case is reported
as a warning, not an error, so the check below passes while initialize() still
raises for an enabled kind that is not registered. Register every enabled kind
before initialization, or set
unknown_component="error" to make validation fail on unknown kinds.
validate() checks only the configuration you pass to it. initialize() also
layers discovered plugins.toml configuration. A preflight report can pass
while the effective startup configuration activates or rejects other
components. Refer to Plugin Configuration
Files when file discovery
participates in deployment.
Append the following validation step to the matching configuration example above. Each example stops deployment when validation reports an error:
Python
Node.js
Rust
Validation Checklist
Before sharing a plugin config contract:
- Validate the smallest correct config.
- Validate a config with each required field missing.
- Validate unsupported enum or mode values.
- Validate unknown component-local fields and their diagnostic levels.
- Validate disabled components with invalid config.
- Confirm diagnostics identify the component and field that needs action.
Common Issues
Check these symptoms first when the workflow does not behave as expected.
- Config contains callables or client objects: Keep config JSON-compatible and instantiate objects inside plugin code.
- Disabled components skip validation: Disabled components should still report config problems.
- Diagnostics are hard to automate: Add stable codes and field names.
- Validation opens network connections: Move runtime setup into plugin registration.
Next Steps
Use these links to continue from this workflow into the next related task.
- Register runtime behavior with Register Plugin Behavior.
- Add rollout controls with Design Plugin Configuration.
- Review concrete validation patterns in Code Examples.