{"record":{"id":"fcf1da5ddfeb9fec","repo":"hashicorp/nomad","slug":"setting-config-for-plugin-s-failed-v","errorCode":null,"errorMessage":"setting config for plugin %s failed: %v","messagePattern":"setting config for plugin (.+?) failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"helper/pluginutils/loader/loader.go","lineNumber":205,"sourceCode":"\t\t}\n\t}\n\n\t// Cast to the base type and set the config\n\tb, ok := instance.Plugin().(base.BasePlugin)\n\tif !ok {\n\t\tinstance.Kill() // Ensure plugin is not left running\n\t\treturn nil, fmt.Errorf(\"plugin %s doesn't implement base plugin interface\", id)\n\t}\n\n\tc := &base.Config{\n\t\tPluginConfig: pinfo.msgpackConfig,\n\t\tAgentConfig:  config,\n\t\tApiVersion:   pinfo.apiVersion,\n\t}\n\n\tif err := b.SetConfig(c); err != nil {\n\t\tinstance.Kill() // ensure plugin is not left running\n\t\treturn nil, fmt.Errorf(\"setting config for plugin %s failed: %v\", id, err)\n\t}\n\n\treturn instance, nil\n}\n\n// Reattach reattaches to a previously launched external plugin.\nfunc (l *PluginLoader) Reattach(name, pluginType string, config *plugin.ReattachConfig) (PluginInstance, error) {\n\treturn l.dispensePlugin(pluginType, \"\", \"\", nil, config, l.logger)\n}\n\n// dispensePlugin is used to launch or reattach to an external plugin.\nfunc (l *PluginLoader) dispensePlugin(\n\tpluginType, apiVersion, cmd string, args []string, reattach *plugin.ReattachConfig,\n\tlogger log.Logger) (PluginInstance, error) {\n\n\tvar pluginCmd *exec.Cmd\n\tif cmd != \"\" && reattach != nil {\n\t\treturn nil, fmt.Errorf(\"both launch command and reattach config specified\")","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/helper/pluginutils/loader/loader.go#L187-L223","documentation":"Dispense, after a successful base cast, calls b.SetConfig with the plugin's msgpack config, the agent config, and API version. If SetConfig fails the instance is killed to avoid a leaked process and this error wraps the plugin's own error. This is the runtime-path counterpart of error 1850, but with a real launched instance.","triggerScenarios":"Dispense (via validatePluginConfig or normal plugin use) when the plugin's SetConfig RPC returns an error: config fails the plugin's own validation, msgpack decode of pinfo.msgpackConfig fails inside the plugin, or the RPC transport breaks.","commonSituations":"Plugin rejects config values it considers invalid despite passing HCL schema validation; plugin process dies during SetConfig; config blob produced at load time doesn't match what the running plugin version expects.","solutions":["Read the wrapped %v message — it contains the plugin's SetConfig rejection reason.","Fix the plugin config in the agent config according to the plugin's error message.","Align the plugin binary version with the agent so msgpackConfig schema and plugin expectations match.","Check plugin stderr/logs for panics during its SetConfig handler.","Rerun validation (`nomad agent config validate`) after correcting the config."],"exampleFix":"// before\nplugin \"qemu\" {\n  config {\n    args = [\"-enable-kvm\"]  # plugin requires image_path\n  }\n}\n// after\nplugin \"qemu\" {\n  config {\n    image_path = \"/opt/images/linux.qcow2\"\n    args       = [\"-enable-kvm\"]\n  }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"inst, err := l.Dispense(name, ptype, agentCfg, logger)\nif err != nil && strings.Contains(err.Error(), \"setting config for plugin\") {\n    // wrapped plugin-side rejection; surface it to config authoring UI/logs\n    return fmt.Errorf(\"plugin rejected its config: %w\", err)\n}","preventionTips":["Run config validation before every agent restart","Keep plugin version aligned with the agent so msgpack config expectations match","Check plugin logs/stderr when SetConfig rejections recur"],"tags":["plugin-loader","config-validation","rpc","nomad"],"backgroundTag":"plugin-config-rejected","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}