{"record":{"id":"e6dc2f90be1ee4d2","repo":"dapr/dapr","slug":"input-key-keyprefix-s-can-t-contain-s","errorCode":null,"errorMessage":"input key/keyPrefix '%s' can't contain '%s'","messagePattern":"input key/keyPrefix '(.+?)' can't contain '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/components/lock/lock_config.go","lineNumber":101,"sourceCode":"\t// Acquire a write lock now to update the value in cache\n\tlocksConfigurationMu.Lock()\n\tdefer locksConfigurationMu.Unlock()\n\n\t// Try checking the cache again after acquiring a write lock, in case another goroutine has created the object\n\tc = lockConfiguration[storeName]\n\tif c != nil {\n\t\treturn c\n\t}\n\n\tc = &StoreConfiguration{keyPrefixStrategy: strategyDefault}\n\tlockConfiguration[storeName] = c\n\n\treturn c\n}\n\nfunc checkKeyIllegal(key string) error {\n\tif strings.Contains(key, separator) {\n\t\treturn fmt.Errorf(\"input key/keyPrefix '%s' can't contain '%s'\", key, separator)\n\t}\n\treturn nil\n}\n","sourceCodeStart":83,"sourceCodeEnd":105,"githubUrl":"https://github.com/dapr/dapr/blob/74ad41702745709bb15fe2114ff693b8c59bc3cc/pkg/components/lock/lock_config.go#L83-L105","documentation":"checkKeyIllegal in the lock building block rejects lock keys, keyPrefix metadata, and keyPrefixStrategy values that contain the Dapr key separator '||' (pkg/components/lock/lock_config.go:18). The lock store composes final store keys as prefix + '||' + lock name, so an embedded '||' would make stored keys ambiguous, and input is rejected before reaching the backend.","triggerScenarios":"Calling TryLock/UnLock with a lock name containing '||' (e.g. 'order||123'), or configuring the lock component's keyPrefix/keyPrefixStrategy metadata with '||' (e.g. 'my||app').","commonSituations":"Using '||' as a visual delimiter in prefixes; passing composite application identifiers that happen to embed the separator; migrating keys from another system that permitted '||'.","solutions":["Replace '||' in the lock name with '-', '_', or another delimiter.","If the offending value is the keyPrefix or keyPrefixStrategy metadata in the component YAML, edit it and re-apply/restart.","Sanitize composite keys at the application boundary (strip or encode '||') before calling the lock API."],"exampleFix":"# before (lock component metadata)\n- name: keyPrefix\n  value: \"orders||prod\"\n\n# after\n- name: keyPrefix\n  value: \"orders-prod\"","handlingStrategy":"validation","validationCode":"const lockSeparator = \"||\" // pkg/components/lock/lock_config.go:18\n\nfunc validLockKey(key string) bool { return !strings.Contains(key, lockSeparator) }\n\n// use before TryLock/UnLock and before setting keyPrefix metadata:\nif !validLockKey(lockName) || !validLockKey(keyPrefix) {\n\treturn errors.New(\"lock name/prefix must not contain '||'\")\n}","typeGuard":null,"tryCatchPattern":"resp, err := lockClient.TryLock(ctx, &lock.TryLockRequest{StoreName: store, ResourceID: resID})\nif err != nil {\n\tif strings.Contains(err.Error(), \"can't contain\") {\n\t\t// reject the caller's identifier early, do not retry\n\t\treturn http.Error(w, \"lock name contains illegal separator '||'\", http.StatusBadRequest)\n\t}\n\treturn err\n}","preventionTips":["Treat '||' as reserved: normalize application identifiers (replace with '-' or '_') before any Dapr call","Add a unit test asserting generated lock names/prefixes never contain '||'","Document the reserved separator for anyone composing keyPrefix metadata"],"tags":["go","dapr","lock","validation","keys"],"backgroundTag":null,"analyzedSha":"74ad41702745709bb15fe2114ff693b8c59bc3cc","analyzedAt":"2026-08-16T04:22:26.543Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}