{"record":{"id":"a99fca6ac4b3b423","repo":"argoproj/argo-workflows","slug":"invalid-lock-kind-s-when-initializing-semaphore","errorCode":null,"errorMessage":"invalid lock kind %s when initializing semaphore","messagePattern":"invalid lock kind (.+?) when initializing semaphore","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"workflow/sync/sync_manager.go","lineNumber":860,"sourceCode":"\t}\n\treturn nil, nil\n}\n\nfunc (sm *Manager) initializeSemaphore(ctx context.Context, semaphoreName string) (semaphore, error) {\n\tlock, err := DecodeLockName(ctx, semaphoreName)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tswitch lock.getKind() {\n\tcase lockKindConfigMap:\n\t\treturn newInternalSemaphore(ctx, semaphoreName, sm.nextWorkflow, sm.getSyncLimit, sm.syncLimitCacheTTL)\n\tcase lockKindDatabase:\n\t\tif sm.dbInfo.SessionProxy == nil {\n\t\t\treturn nil, fmt.Errorf(\"database session is not available for semaphore %s\", semaphoreName)\n\t\t}\n\t\treturn newDatabaseSemaphore(ctx, semaphoreName, lock.getDBKey(), sm.nextWorkflow, sm.dbInfo, sm.syncLimitCacheTTL)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"invalid lock kind %s when initializing semaphore\", lock.getKind())\n\t}\n}\n\nfunc (sm *Manager) initializeMutex(ctx context.Context, mutexName string) (semaphore, error) {\n\tlock, err := DecodeLockName(ctx, mutexName)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tswitch lock.getKind() {\n\tcase lockKindMutex:\n\t\treturn newInternalMutex(mutexName, sm.nextWorkflow), nil\n\tcase lockKindDatabase:\n\t\tif sm.dbInfo.SessionProxy == nil {\n\t\t\treturn nil, fmt.Errorf(\"database session is not available for mutex %s\", mutexName)\n\t\t}\n\t\treturn newDatabaseMutex(mutexName, lock.getDBKey(), sm.nextWorkflow, sm.dbInfo), nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"invalid lock kind %s when initializing mutex\", lock.getKind())","sourceCodeStart":842,"sourceCodeEnd":878,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/workflow/sync/sync_manager.go#L842-L878","documentation":"initializeSemaphore decoded the lock name but the resulting kind is neither configmap nor database, so no semaphore implementation exists and 'invalid lock kind %s when initializing semaphore' is returned. This indicates an unrecognized or corrupted lock kind value reaching the semaphore factory.","triggerScenarios":"DecodeLockName returns a lock whose getKind() hits the default branch — a lock name encoded with an unknown kind constant (corrupted state, hand-edited sync data, or incompatible version).","commonSituations":"Version skew between controllers sharing sync state; manual edits to sync ConfigMaps; custom or experimental lock kinds from a patched build.","solutions":["Log the offending kind value from the error to identify the source","Align all controllers on the same argo-workflows version","Regenerate/recreate the sync lock from a valid workflow synchronization reference","Remove the corrupted lock record so it is rebuilt correctly"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"lock, err := sync.DecodeLockName(ctx, name)\nif err != nil || (lock.GetKind() != sync.LockKindConfigMap && lock.GetKind() != sync.LockKindDatabase) {\n    return fmt.Errorf(\"unsupported lock kind for %q\", name)\n}","typeGuard":"func knownLockKind(k sync.LockKind) bool {\n    return k == sync.LockKindConfigMap || k == sync.LockKindDatabase\n}","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"invalid lock kind\") { /* discard corrupted lock, rebuild from spec */ }","preventionTips":["Never hand-edit encoded lock names or sync state","Run homogeneous controller versions across replicas","Round-trip test DecodeLockName/encode in CI"],"tags":["argo-workflows","sync","semaphore","decoding","version-mismatch"],"backgroundTag":"unknown-lock-kind","analyzedSha":"35bff19146f5a6ada77468c431f2624bd577e373","analyzedAt":"2026-09-03T19:34:35.908Z","contentChangedAt":"2026-09-03T19:34:35.908Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}