{"record":{"id":"6507590cd4ab2be2","repo":"hashicorp/nomad","slug":"invalid-suffix","errorCode":null,"errorMessage":"invalid suffix","messagePattern":"invalid suffix","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/agent/monitor/export_monitor.go","lineNumber":156,"sourceCode":"\tif len(splitInput) < 2 {\n\t\tprefix = input\n\t} else {\n\t\tsuffix := splitInput[len(splitInput)-1]\n\t\tvalidSuffix := []string{\n\t\t\t\"service\",\n\t\t\t\"socket\",\n\t\t\t\"device\",\n\t\t\t\"mount\",\n\t\t\t\"automount\",\n\t\t\t\"swap\",\n\t\t\t\"target\",\n\t\t\t\"path\",\n\t\t\t\"timer\",\n\t\t\t\"slice\",\n\t\t\t\"scope\",\n\t\t}\n\t\tif valid := slices.Contains(validSuffix, suffix); !valid {\n\t\t\treturn errors.New(\"invalid suffix\")\n\t\t}\n\t\tprefix = strings.Join(splitInput[:len(splitInput)-1], \"\")\n\t}\n\n\tsafe, _ := regexp.MatchString(`^[\\w\\\\._-]*(@[\\w\\\\._-]+)?$`, prefix)\n\tif !safe {\n\t\treturn fmt.Errorf(\"%s does not meet systemd conventions\", prefix)\n\t}\n\treturn nil\n}\n\nfunc cliReader(opts MonitorExportOpts) (*ExportReader, error) {\n\tisCli := true\n\t// Vet servicename again\n\tif err := ScanServiceName(opts.ServiceName); err != nil {\n\t\treturn nil, err\n\t}\n\tcmdDuration := \"72 hours\"","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/agent/monitor/export_monitor.go#L138-L174","documentation":"ScanServiceName splits the input on '.'; when a suffix exists, it must be one of the valid systemd unit types (service, path, timer, slice, scope, etc.) checked via slices.Contains. If the suffix is not in that list, the function returns this error. This guards against unsupported or malformed systemd unit suffixes being passed to journald export.","triggerScenarios":"Passing a unit name whose dot-suffix is not a recognized systemd unit type — e.g. `nomad-job.conf`, `nomad.service.bak`, `nomad.foo` — to AgentMonitorExport or the CLI reader.","commonSituations":"Typos in suffix (`.servcie`), passing file names instead of unit names, extra dots creating an unexpected last segment, or users specifying socket/mount units that are not in Nomad's valid list.","solutions":["Use a valid systemd suffix: `.service`, `.path`, `.timer`, `.slice`, `.scope` (or others in Nomad's validSuffix list), e.g. `nomad-client.service`.","Remove file extensions or extra dots from the configured name.","Check the exact unit name with `systemctl status <name>` and pass the canonical unit name.","If monitoring a unit type Nomad rejects, monitor it directly with journalctl instead."],"exampleFix":"// before\nScanServiceName(\"nomad-client.servcie\")\n// after\nScanServiceName(\"nomad-client.service\")","handlingStrategy":"validation","validationCode":"var validSuffix = map[string]bool{\"service\": true, \"path\": true, \"timer\": true, \"slice\": true, \"scope\": true}\nparts := strings.Split(serviceName, \".\")\nif len(parts) >= 2 && !validSuffix[parts[len(parts)-1]] {\n    return fmt.Errorf(\"unsupported systemd suffix .%s\", parts[len(parts)-1])\n}","typeGuard":null,"tryCatchPattern":"if err := monitor.ScanServiceName(name); err != nil {\n    if strings.Contains(err.Error(), \"invalid suffix\") {\n        return fmt.Errorf(\"use a valid systemd unit suffix (.service, .timer, ...) for %q\", name)\n    }\n    return err\n}","preventionTips":["Use canonical unit names from `systemctl status`, not file names with stray extensions.","Strip backup extensions like .bak before submitting names.","Restrict monitoring config to .service units Nomad manages."],"tags":["systemd","validation","naming","journald"],"backgroundTag":"invalid-service-name","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}