{"record":{"id":"792589d439d7ff56","repo":"hashicorp/nomad","slug":"error-creating-volume-q-with-plugin-q-w","errorCode":null,"errorMessage":"error creating volume %q with plugin %q: %w","messagePattern":"error creating volume %q with plugin %q: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/hostvolumemanager/host_volume_plugin.go","lineNumber":360,"sourceCode":"\t\tfmt.Sprintf(\"%s=%s\", EnvNamespace, req.Namespace),\n\t\tfmt.Sprintf(\"%s=%s\", EnvVolumeName, req.Name),\n\t\tfmt.Sprintf(\"%s=%s\", EnvVolumeID, req.ID),\n\t\tfmt.Sprintf(\"%s=%d\", EnvCapacityMin, req.RequestedCapacityMinBytes),\n\t\tfmt.Sprintf(\"%s=%d\", EnvCapacityMax, req.RequestedCapacityMaxBytes),\n\t\tfmt.Sprintf(\"%s=%s\", EnvNodeID, req.NodeID),\n\t\tfmt.Sprintf(\"%s=%s\", EnvParameters, params),\n\t}\n\n\tvar pluginResp HostVolumePluginCreateResponse\n\tlog := p.log.With(\"volume_name\", req.Name, \"volume_id\", req.ID)\n\tstdout, _, err := p.runPlugin(ctx, log, \"create\", envVars)\n\tif err != nil {\n\t\tjsonErr := json.Unmarshal(stdout, &pluginResp)\n\t\tif jsonErr != nil {\n\t\t\t// if we got an error, we can't actually count on getting JSON, so\n\t\t\t// optimistically look for it and return the original error\n\t\t\t// otherwise\n\t\t\treturn nil, fmt.Errorf(\n\t\t\t\t\"error creating volume %q with plugin %q: %w\", req.ID, p.ID, err)\n\t\t}\n\t\treturn nil, fmt.Errorf(\"error creating volume %q with plugin %q: %w: %s\",\n\t\t\treq.ID, p.ID, err, pluginResp.Error)\n\t}\n\terr = json.Unmarshal(stdout, &pluginResp)\n\tif err != nil {\n\t\t// note: if a plugin does not return valid json, a volume may be\n\t\t// created without any respective state in Nomad, since we return\n\t\t// an error here after the plugin has done who-knows-what.\n\t\treturn nil, err\n\t}\n\treturn &pluginResp, nil\n}\n\n// Delete calls the executable with the following parameters:\n// arguments: $1=delete\n// environment:","sourceCodeStart":342,"sourceCodeEnd":378,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/hostvolumemanager/host_volume_plugin.go#L342-L378","documentation":"Returned by HostVolumePluginExternal.Create when the external plugin executable exits non-zero AND its stdout could not be parsed as JSON, so Nomad wraps the original execution error with the volume ID and plugin ID. Because no structured response is available, only the original error is propagated (no pluginResp.Error detail).","triggerScenarios":"The plugin binary invoked by Create fails (non-zero exit) and prints no valid JSON on stdout — e.g. crash, missing interpreter, hard failure before emitting a response.","commonSituations":"Plugin executable missing/shebang broken; plugin crashing on bad parameters; plugin writing errors only to stderr; wrong plugin directory configured so an incompatible script runs; script has a bug that skips JSON output on failure.","solutions":["Run the plugin manually with the same env vars (NOMAD_OPERATION=create etc.) to reproduce the failure","Check the plugin's stderr output in the Nomad client logs for the root cause","Verify p.ID and p.PluginDir point at the intended executable and it is executable","Fix or reinstall the plugin script so it emits JSON even on error","Validate req.ID / parameters against the plugin's expected schema"],"exampleFix":"// before\n$ /opt/nomad-plugins/create.sh  # crashes, no JSON on stdout\n// after\n$ chmod +x /opt/nomad-plugins/create.sh && head -1 create.sh  # ensure '#!/bin/sh'\n$ # fix script to output {\"error\": \"...\"} on failure","handlingStrategy":"try-catch","validationCode":"fi, err := os.Stat(pluginPath)\nif err != nil || fi.Mode()&0o111 == 0 {\n    return fmt.Errorf(\"plugin %s missing or not executable\", pluginPath)\n}","typeGuard":"func isPluginExecErr(err error) bool {\n    return strings.Contains(err.Error(), \"with plugin\") && !strings.Contains(err.Error(), \": \") // no pluginResp suffix\n}","tryCatchPattern":"resp, err := plugin.Create(ctx, req)\nif err != nil {\n    var perr *SomeRetryable = nil\n    if errors.As(err, &perr) { /* retry */ }\n    log.Error(\"plugin create failed without JSON response; check plugin stderr in client logs\", \"err\", err)\n    return err\n}","preventionTips":["Smoke-test the plugin binary manually with NOMAD_OPERATION=create before registering","Ensure the script is executable with a correct shebang","Make plugins emit JSON (with an error field) even on failure","Pin plugin versions compatible with your Nomad release"],"tags":["host-volumes","external-plugin","process-execution"],"backgroundTag":"plugin-execution-failed","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"}