{"record":{"id":"8d720f225213f430","repo":"Tencent/WeKnora","slug":"redis-lock-callback-is-required","errorCode":null,"errorMessage":"redis lock callback is required","messagePattern":"redis lock callback is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/common/redislock/token_lock.go","lineNumber":162,"sourceCode":"\t).Int64()\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"renew redis lock %q: %w\", key, err)\n\t}\n\treturn renewed != 0, nil\n}\n\n// WithRenewableLock acquires key, renews it while fn runs, and atomically\n// releases it on exit. Renewal failure cancels the context passed to fn.\nfunc WithRenewableLock(\n\tctx context.Context,\n\tclient redis.UniversalClient,\n\tkey string,\n\tlease time.Duration,\n\trenewInterval time.Duration,\n\tfn func(context.Context) error,\n) (resultErr error) {\n\tif fn == nil {\n\t\treturn errors.New(\"redis lock callback is required\")\n\t}\n\tif renewInterval <= 0 || renewInterval >= lease {\n\t\treturn errors.New(\"redis lock renewal interval must be positive and shorter than the lease\")\n\t}\n\n\ttoken, err := NewToken()\n\tif err != nil {\n\t\treturn err\n\t}\n\tif err := Acquire(ctx, client, key, token, lease); err != nil {\n\t\treturn err\n\t}\n\n\tlockCtx, cancelLock := context.WithCancelCause(ctx)\n\townershipCtx, cancelOwnership := context.WithCancelCause(context.Background())\n\tlockCtx = context.WithValue(lockCtx, ownershipContextKey{}, ownershipCtx)\n\trenewCtx, stopRenewal := context.WithCancel(context.WithoutCancel(ctx))\n\trenewResult := make(chan error, 1)","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/common/redislock/token_lock.go#L144-L180","documentation":"Argument guard raised by redislock.WithRenewableLock when fn is nil — there is no callback to run under the lock, so acquisition is pointless and refused before touching Redis. Programming-error guard.","triggerScenarios":"Thrown at internal/common/redislock/token_lock.go:162 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a non-nil callback to WithRenewableLock","Check the call site — a nil fn usually means an uninitialized closure or a misconfigured code path"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}