{"record":{"id":"b96db367a5ed51af","repo":"dotnetcore/CAP","slug":"delay-time-span-must-be-greater-than-0-parameter-delaytime","errorCode":null,"errorMessage":"Delay time span must be greater than 0 (Parameter 'delayTime')","messagePattern":"Delay time span must be greater than 0 \\(Parameter 'delayTime'\\)","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/DotNetCore.CAP/Internal/ICapPublisher.Default.cs","lineNumber":75,"sourceCode":"        await PublishInternalAsync(name, value, headers, null, cancellationToken).ConfigureAwait(false);\n    }\n\n    public async Task PublishAsync<T>(string name, T? value, string? callbackName = null,\n        CancellationToken cancellationToken = default)\n    {\n        var headers = new Dictionary<string, string?>\n        {\n            { Headers.CallbackName, callbackName }\n        };\n        await PublishAsync(name, value, headers, cancellationToken).ConfigureAwait(false);\n    }\n\n    public async Task PublishDelayAsync<T>(TimeSpan delayTime, string name, T? value, IDictionary<string, string?> headers,\n        CancellationToken cancellationToken = default)\n    {\n        if (delayTime <= TimeSpan.Zero)\n        {\n            throw new ArgumentException(\"Delay time span must be greater than 0\", nameof(delayTime));\n        }\n\n        await PublishInternalAsync(name, value, headers, delayTime, cancellationToken).ConfigureAwait(false);\n    }\n\n    public async Task PublishDelayAsync<T>(TimeSpan delayTime, string name, T? value, string? callbackName = null,\n        CancellationToken cancellationToken = default)\n    {\n        var header = new Dictionary<string, string?>\n        {\n            { Headers.CallbackName, callbackName }\n        };\n\n        await PublishDelayAsync(delayTime, name, value, header, cancellationToken).ConfigureAwait(false);\n    }\n\n    public void Publish<T>(string name, T? value, string? callbackName = null)\n    {","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/dotnetcore/CAP/blob/e52b8508e54cdb7a9ce7f9fec03d9ea8ad2710fb/src/DotNetCore.CAP/Internal/ICapPublisher.Default.cs#L57-L93","documentation":"An argument guard in the default ICapPublisher's PublishDelayAsync: the delayTime TimeSpan passed by the caller must represent a positive delay. Passing zero, a negative TimeSpan, or a default(TimeSpan) makes delayed publishing meaningless (it would be an immediate publish), so ArgumentException fires before any message is enqueued.","triggerScenarios":"Thrown at src/DotNetCore.CAP/Internal/ICapPublisher.Default.cs:75 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a positive TimeSpan, e.g. await publisher.PublishDelayAsync(TimeSpan.FromMinutes(5), \"order.created\", payload).","When delay is computed dynamically, guard it first: if (delay <= TimeSpan.Zero) use PublishAsync instead of PublishDelayAsync."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e52b8508e54cdb7a9ce7f9fec03d9ea8ad2710fb","analyzedAt":"2026-09-14T14:46:34.677Z","contentChangedAt":"2026-09-14T14:46:34.677Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}