{"record":{"id":"a0b053d7bae02f90","repo":"hashicorp/nomad","slug":"invalid-plugin-loader-configuration-passed-v","errorCode":null,"errorMessage":"invalid plugin loader configuration passed: %v","messagePattern":"invalid plugin loader configuration passed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"helper/pluginutils/loader/loader.go","lineNumber":122,"sourceCode":"\tbaseInfo   *base.PluginInfoResponse\n\tversion    *version.Version\n\tapiVersion string\n\n\tconfigSchema  *hclspec.Spec\n\tconfig        map[string]interface{}\n\tmsgpackConfig []byte\n}\n\n// NewPluginLoader returns an instance of a plugin loader or an error if the\n// plugins could not be loaded\n//\n// IMPORTANT: This function will mutate the passed in config to update the plugin\n// configs with any default values from the plugin's config schema.\n// The config should be a pointer to the config in the agent to properly\n// update the plugin configs in the agent.\nfunc NewPluginLoader(config *PluginLoaderConfig) (*PluginLoader, error) {\n\tif err := validateConfig(config); err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid plugin loader configuration passed: %v\", err)\n\t}\n\n\t// Convert the versions\n\tsupportedVersions := make(map[string][]*version.Version, len(config.SupportedVersions))\n\tfor pType, versions := range config.SupportedVersions {\n\t\tconverted, err := convertVersions(versions)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tsupportedVersions[pType] = converted\n\t}\n\n\tlogger := config.Logger.Named(\"plugin_loader\").With(\"plugin_dir\", config.PluginDir)\n\tl := &PluginLoader{\n\t\tlogger:            logger,\n\t\tsupportedVersions: supportedVersions,\n\t\tpluginDir:         config.PluginDir,\n\t\tplugins:           make(map[PluginID]*pluginInfo),","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/helper/pluginutils/loader/loader.go#L104-L140","documentation":"NewPluginLoader rejects its PluginLoaderConfig argument when validateConfig fails, wrapping the validation error in this message. The loader requires an agent config, supported versions map, plugin directory, and logger; a nil or incomplete config makes it impossible to construct a PluginLoader.","triggerScenarios":"Calling NewPluginLoader (directly, in tests like TestPluginLoaderWithOptions, or via setupPlugins/dockerDriverHarness) with a nil *PluginLoaderConfig, nil config.AgentConfig, nil config.SupportedVersions, empty config.PluginDir, or nil config.Logger — whatever validateConfig enforces.","commonSituations":"Unit tests constructing a PluginLoader with a partially populated PluginLoaderConfig; embedding Nomad plugin loading in another tool and forgetting to set Logger or PluginDir; passing a config struct zero value.","solutions":["Read the wrapped %v detail to see which required field failed validation.","Populate all required PluginLoaderConfig fields: AgentConfig, SupportedVersions, PluginDir, Logger.","Build the config via a constructor/helper instead of a bare &PluginLoaderConfig{} literal.","In tests, use a fixture that sets defaults for every required field."],"exampleFix":"// before\nl, err := NewPluginLoader(&loader.PluginLoaderConfig{AgentConfig: cfg})\n// after\nl, err := NewPluginLoader(&loader.PluginLoaderConfig{\n  AgentConfig:       cfg,\n  Config:            pluginsConfig,\n  PluginDir:         cfg.PluginDir,\n  SupportedVersions: supportedVersions,\n  Logger:            logger,\n})","handlingStrategy":"validation","validationCode":"func validLoaderConfig(c *loader.PluginLoaderConfig) bool {\n    return c != nil &&\n        c.AgentConfig != nil &&\n        c.PluginDir != \"\" &&\n        c.Logger != nil &&\n        c.SupportedVersions != nil\n}","typeGuard":"func isValidLoaderConfig(c interface{}) bool {\n    cfg, ok := c.(*loader.PluginLoaderConfig)\n    return ok && cfg != nil && cfg.AgentConfig != nil && cfg.Logger != nil\n}","tryCatchPattern":"l, err := loader.NewPluginLoader(cfg)\nif err != nil {\n    return fmt.Errorf(\"loader config invalid: %w\", err) // %v detail names the field\n}","preventionTips":["Use a constructor/fixture that sets every PluginLoaderConfig field","Never pass zero-value structs to NewPluginLoader","Assert required fields non-nil in test setup helpers"],"tags":["plugin-loader","config-validation","constructor","nomad"],"backgroundTag":"invalid-loader-config","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"}