{"record":{"id":"823715cfb10cc023","repo":"hashicorp/nomad","slug":"unknown-service-registration-provider-q","errorCode":null,"errorMessage":"unknown service registration provider: %q","messagePattern":"unknown service registration provider: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/serviceregistration/wrapper/wrapper.go","lineNumber":63,"sourceCode":"// function. It determines which backend provider to call and passes the\n// workload unless the provider is unknown, in which case an error will be\n// returned.\nfunc (h *HandlerWrapper) RegisterWorkload(workload *serviceregistration.WorkloadServices) error {\n\n\t// Don't rely on callers to check there are no services to register.\n\tif len(workload.Services) == 0 {\n\t\treturn nil\n\t}\n\n\tprovider := workload.RegistrationProvider()\n\n\tswitch provider {\n\tcase structs.ServiceProviderNomad:\n\t\treturn h.nomadServiceProvider.RegisterWorkload(workload)\n\tcase structs.ServiceProviderConsul:\n\t\treturn h.consulServiceProvider.RegisterWorkload(workload)\n\tdefault:\n\t\treturn fmt.Errorf(\"unknown service registration provider: %q\", provider)\n\t}\n}\n\n// RemoveWorkload wraps the serviceregistration.Handler RemoveWorkload\n// function. It determines which backend provider to call and passes the\n// workload unless the provider is unknown.\nfunc (h *HandlerWrapper) RemoveWorkload(services *serviceregistration.WorkloadServices) {\n\n\tvar provider string\n\n\t// It is possible the services field is empty depending on the exact\n\t// situation which resulted in the call.\n\tif len(services.Services) > 0 {\n\t\tprovider = services.RegistrationProvider()\n\t}\n\n\t// Call the correct provider, if we have managed to identify it. An empty\n\t// string means you didn't find a provider, therefore default to consul.","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/serviceregistration/wrapper/wrapper.go#L45-L81","documentation":"The service registration wrapper dispatches RegisterWorkload to the registered backend (Nomad or Consul) based on the workload's provider string. If the provider is neither \"nomad\" nor \"consul\", the wrapper returns this error because no handler exists for it.","triggerScenarios":"A service stanza (or code path building WorkloadRegistrations) carries a provider value other than structs.ServiceProviderNomad or structs.ServiceProviderConsul into wrapper.RegisterWorkload — e.g. from a hand-crafted job, an API submission bypassing validation, or stale/foreign data.","commonSituations":"Job spec sets provider = \"consul-nomad\" or similar typo; job created for a newer Nomad that supports a provider the running client does not know; tooling generating registrations with empty/garbage provider fields.","solutions":["Set provider to \"nomad\" or \"consul\" explicitly in each service stanza","Remove invalid/empty provider fields so defaults apply and validation passes","Ensure client binary version supports the provider used in the job (upgrade Nomad if needed)","Run nomad job validate before submission to catch unknown provider values"],"exampleFix":"// before\nservice {\n  name = \"web\"\n  provider = \"consul-nomad\"\n}\n// after\nservice {\n  name = \"web\"\n  provider = \"consul\"\n}","handlingStrategy":"validation","validationCode":"switch provider {\ncase \"nomad\", \"consul\":\n    // ok\ndefault:\n    return fmt.Errorf(\"refusing to register: unsupported provider %q\", provider)\n}","typeGuard":"func knownProvider(p string) bool {\n    return p == structs.ServiceProviderNomad || p == structs.ServiceProviderConsul\n}","tryCatchPattern":"err := wrapper.RegisterWorkload(workload)\nif err != nil && strings.HasPrefix(err.Error(), \"unknown service registration provider\") {\n    logger.Error(\"bad provider in workload registration\", \"provider\", workload.Provider)\n    return err\n}","preventionTips":["Always set provider explicitly (\"nomad\" or \"consul\") in service stanzas","Run nomad job validate before submission to catch unknown provider values","Keep client Nomad version >= the version that introduced any provider you use","Lint generated job specs for empty/garbage provider fields"],"tags":["nomad","service-registration","invalid-enum","provider"],"backgroundTag":"unknown-provider","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"}