{"record":{"id":"254b5d480ad76d26","repo":"hashicorp/nomad","slug":"context-must-be-one-of-v-or-all-for-all-context","errorCode":null,"errorMessage":"context must be one of %v or 'all' for all contexts; got %q","messagePattern":"context must be one of (.+?) or 'all' for all contexts; got %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/search_endpoint_ce.go","lineNumber":44,"sourceCode":"\t// Handle cases where context name and state store table name do not match\n\tcase structs.Variables:\n\t\treturn state.TableVariables\n\tdefault:\n\t\treturn string(ctx)\n\t}\n}\n\n// getEnterpriseMatch is a no-op in oss since there are no enterprise objects.\nfunc getEnterpriseMatch(match any) (id string, ok bool) {\n\treturn \"\", false\n}\n\n// getEnterpriseResourceIter is used to retrieve an iterator over an enterprise\n// only table.\nfunc getEnterpriseResourceIter(context structs.Context, _ *acl.ACL, namespace, prefix string, ws memdb.WatchSet, state *state.StateStore) (memdb.ResultIterator, error) {\n\t// If we have made it here then it is an error since we have exhausted all\n\t// open source contexts.\n\treturn nil, fmt.Errorf(\"context must be one of %v or 'all' for all contexts; got %q\", allContexts, context)\n}\n\n// getEnterpriseFuzzyResourceIter is used to retrieve an iterator over an enterprise\n// only table.\nfunc getEnterpriseFuzzyResourceIter(context structs.Context, _ *acl.ACL, _ string, _ memdb.WatchSet, _ *state.StateStore) (memdb.ResultIterator, error) {\n\treturn nil, fmt.Errorf(\"context must be one of %v or 'all' for all contexts; got %q\", allContexts, context)\n}\n\nfunc filteredSearchContextsEnt(aclObj *acl.ACL, namespace string, context structs.Context) bool {\n\treturn true\n}\n","sourceCodeStart":26,"sourceCodeEnd":56,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/search_endpoint_ce.go#L26-L56","documentation":"In Nomad's open-source build, getEnterpriseResourceIter is a hook that should only be reached for enterprise-only search contexts. Reaching it means the requested context did not match any open-source context, so it always returns this error listing the valid contexts (allContexts). It is the terminal fallback of getResourceIter's context dispatch.","triggerScenarios":"Calling the Search RPC with a Context value that is not one of the OSS contexts (e.g. an enterprise-only context like \"quotas\", \"namespaces\" enterprise variants, or any misspelled/invalid string) — or the string failing to equal any known context or 'all'.","commonSituations":"Typo in the context string sent by automation; tools written against Nomad Enterprise (contexts like 'multi-region' or quota contexts) pointed at an OSS cluster; stale SDK versions enumerating contexts the running server doesn't know.","solutions":["Use a valid OSS context from the error's list (volumes, allocation, deployment, task_group, evaluation, job, node, agents) or \"all\"","Fix typos/casing in the Context field of the SearchRequest","If enterprise contexts are required, run Nomad Enterprise instead of OSS"],"exampleFix":"// before\nreq := &api.SearchRequest{Context: \"quotas\"}\n// after\nreq := &api.SearchRequest{Context: structs.ContextsJob} // or \"all\"","handlingStrategy":"validation","validationCode":"validContexts := map[string]bool{\n  \"volumes\": true, \"allocation\": true, \"deployment\": true,\n  \"task_group\": true, \"evaluation\": true, \"job\": true,\n  \"node\": true, \"agents\": true, \"all\": true,\n}\nif !validContexts[req.Context] {\n    return fmt.Errorf(\"unsupported context %q for OSS Nomad\", req.Context)\n}","typeGuard":"func isValidSearchContext(c string) bool {\n    switch structs.Context(c) {\n    case structs.ContextsVolumes, structs.ContextsAllocation, structs.ContextsDeployment,\n        structs.ContextsTaskGroup, structs.ContextsEvaluation, structs.ContextsJob,\n        structs.ContextsNode, structs.ContextsAgent, structs.All:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Only send contexts enumerated in the error message (allContexts) or \"all\"","Never assume enterprise-only contexts exist on an OSS cluster","Derive context values from constants (structs.Contexts*) instead of raw strings"],"tags":["nomad","go","search","invalid-context"],"backgroundTag":"invalid-enum-value","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"}