{"record":{"id":"0d851dfc494b4610","repo":"hashicorp/nomad","slug":"unspecified-lock-operation","errorCode":null,"errorMessage":"unspecified lock operation","messagePattern":"unspecified lock operation","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"command/agent/variable_endpoint.go","lineNumber":309,"sourceCode":"\t_, releaseLock := queryParams[releaseLockQueryParam]\n\n\tif !renewLock && !acquireLock && !releaseLock {\n\t\treturn \"\", nil\n\t}\n\n\tif !isOneAndOnlyOneSet(renewLock, acquireLock, releaseLock) {\n\t\treturn \"\", errors.New(\"multiple lock operations\")\n\t}\n\n\tswitch {\n\tcase renewLock:\n\t\treturn renewLockQueryParam, nil\n\tcase acquireLock:\n\t\treturn acquireLockQueryParam, nil\n\tcase releaseLock:\n\t\treturn releaseLockQueryParam, nil\n\tdefault:\n\t\treturn \"\", errors.New(\"unspecified lock operation\")\n\t}\n}\n","sourceCodeStart":291,"sourceCodeEnd":312,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/agent/variable_endpoint.go#L291-L312","documentation":"getLockOperation falls through to its default case when none of the renewLock/acquireLock/releaseLock flags matched despite having passed the earlier 'at least one set' check — a defensive unreachable-in-practice branch. It returns this error to guarantee the function always returns a valid lock operation string or an explicit error rather than an empty one.","triggerScenarios":"Only reachable if the boolean flags are in an inconsistent state relative to the earlier checks (e.g. flags mutated concurrently or the one-and-only-one check logic diverges from the switch). Normal API callers cannot hit it with well-formed requests.","commonSituations":"Custom forks/patches modifying getLockOperation; concurrent mutation of parsed request fields; refactoring that changes how flags are set before the switch without updating the guard checks.","solutions":["No user action needed for stock Nomad; treat this as an internal invariant. Report a bug with reproduction steps if you genuinely see it.","If you maintain a fork, align the guard checks (renewLock/acquireLock/releaseLock conditions) with the switch cases so they cover identical conditions.","Audit any middleware that rewrites variable requests in-flight and could corrupt the parsed flags.","Pin to an official Nomad release rather than a patched build if the error appears without a clear cause."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if count == 1 {\n    // exactly one op set — default case cannot be reached\n}","typeGuard":null,"tryCatchPattern":"if err := updateVariable(req); err != nil {\n    if strings.Contains(err.Error(), \"unspecified lock operation\") {\n        log.Printf(\"internal invariant violation in lock op parsing; report to Nomad with request dump\")\n        return err\n    }\n    return err\n}","preventionTips":["Use official Nomad releases; this path is unreachable in stock code.","Fork maintainers: keep guard checks and switch cases synchronized.","Avoid middleware that mutates parsed variable request fields in flight."],"tags":["variables","lock","invariant","unreachable"],"backgroundTag":"unhandled-switch-case","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"}