{"record":{"id":"4c74e06eb4b854a1","repo":"VictoriaMetrics/VictoriaMetrics","slug":"skipping-unexpected-role-q-must-be-one-of-tasks","errorCode":null,"errorMessage":"skipping unexpected role=%q; must be one of `tasks`, `services` or `nodes`","messagePattern":"skipping unexpected role=%q; must be one of `tasks`, `services` or `nodes`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"lib/promscrape/discovery/dockerswarm/dockerswarm.go","lineNumber":53,"sourceCode":"\tName   string   `yaml:\"name\"`\n\tValues []string `yaml:\"values\"`\n}\n\n// GetLabels returns dockerswarm labels according to sdc.\nfunc (sdc *SDConfig) GetLabels(baseDir string) ([]*promutil.Labels, error) {\n\tcfg, err := getAPIConfig(sdc, baseDir)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot get API config: %w\", err)\n\t}\n\tswitch sdc.Role {\n\tcase \"tasks\":\n\t\treturn getTasksLabels(cfg)\n\tcase \"services\":\n\t\treturn getServicesLabels(cfg)\n\tcase \"nodes\":\n\t\treturn getNodesLabels(cfg)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"skipping unexpected role=%q; must be one of `tasks`, `services` or `nodes`\", sdc.Role)\n\t}\n}\n\n// MustStop stops further usage for sdc.\nfunc (sdc *SDConfig) MustStop() {\n\tv := configMap.Delete(sdc)\n\tif v != nil {\n\t\tcfg := v.(*apiConfig)\n\t\tcfg.client.Stop()\n\t}\n}\n","sourceCodeStart":35,"sourceCodeEnd":65,"githubUrl":"https://github.com/VictoriaMetrics/VictoriaMetrics/blob/5079fb58f1e8e62113f90c945ad71586c797d770/lib/promscrape/discovery/dockerswarm/dockerswarm.go#L35-L65","documentation":"GetLabels dispatches on sdc.Role and only recognizes `tasks`, `services` or `nodes`; anything else returns this error. Docker Swarm roles map to different API endpoints, so an unknown role cannot be queried. This is a validation error in the SD config, surfaced during discovery instead of silently returning zero targets.","triggerScenarios":"dockerswarm SD config's `role` field is empty, misspelled (e.g. 'task', 'Services', 'container'), or set to a value not in {tasks, services, nodes}.","commonSituations":"Copy-pasted config from a generic Docker SD example; YAML key edited by hand; older configs using a role name that never existed in this library; case sensitivity mistakes.","solutions":["Set role to exactly one of: tasks, services, nodes (lowercase)","Check for typos and surrounding whitespace/quotes in the YAML value","Validate the config with the config-check flag before reload","Consult the dockerswarm SD docs for the role you actually want"],"exampleFix":"// before\n- role: task\n// after\n- role: tasks","handlingStrategy":"validation","validationCode":"// Go: assert role membership before building the SD config\nvar validRoles = map[string]bool{\"tasks\": true, \"services\": true, \"nodes\": true}\nif !validRoles[role] {\n    return fmt.Errorf(\"role %q invalid: must be tasks, services or nodes\", role)\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Copy role values verbatim from docs; they are lowercase and singular","Template-validate generated configs against the allowed role set","Lint YAML so stray case/whitespace changes are caught in review"],"tags":["docker-swarm","service-discovery","validation","config"],"backgroundTag":"invalid-enum-value","analyzedSha":"5079fb58f1e8e62113f90c945ad71586c797d770","analyzedAt":"2026-09-03T18:10:26.153Z","contentChangedAt":"2026-09-03T18:10:26.153Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}