{"record":{"id":"3e6e4909831a40df","repo":"stride3d/stride","slug":"value-must-be-0","errorCode":null,"errorMessage":"Value must be > 0","messagePattern":"Value must be > 0","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core/Diagnostics/LogListener.cs","lineNumber":65,"sourceCode":"    /// <summary>\n    /// Gets the per-module overrides of <see cref=\"MinimumLevel\"/>, keyed by <see cref=\"ILogMessage.Module\"/>.\n    /// A listener can stay quiet overall while still following a few modules in detail. Safe to\n    /// update while the listener is attached.\n    /// </summary>\n    public ConcurrentDictionary<string, LogMessageType> ModuleLevels { get; } = new();\n\n    /// <summary>\n    /// Gets or sets the log count flush limit. Default is on every message.\n    /// </summary>\n    /// <value>The log count flush limit.</value>\n    public int LogCountFlushLimit\n    {\n        get { return logCountFlushLimit; }\n        set\n        {\n            if (value <= 0)\n            {\n                throw new ArgumentException(\"Value must be > 0\");\n            }\n\n            logCountFlushLimit = value;\n        }\n    }\n\n    /// <summary>\n    /// Called when a log occurred.\n    /// </summary>\n    /// <param name=\"logMessage\">The log message.</param>\n    protected abstract void OnLog(ILogMessage logMessage);\n\n    /// <summary>\n    /// Returns whether a message passes this listener's filter, and so should reach <see cref=\"OnLog\"/>.\n    /// The default compares its severity against <see cref=\"ModuleLevels\"/>, falling back to\n    /// <see cref=\"MinimumLevel\"/>. Override to add conditions of your own.\n    /// </summary>\n    /// <param name=\"logMessage\">The log message.</param>","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core/Diagnostics/LogListener.cs#L47-L83","documentation":"LogListener.LogCountFlushLimit is a property guard: the setter rejects any value <= 0 with ArgumentException because the limit controls how many buffered log messages accumulate before a forced flush; zero or negative would make the flush logic meaningless or divide the flush loop into an invalid count.","triggerScenarios":"Assigning listener.LogCountFlushLimit = 0 (or any negative number) in listener setup code, or computing the limit from config/appsettings where a missing or zero value is passed through unvalidated.","commonSituations":"Reading the limit from a config file where 0 means 'unlimited' to the developer but the API requires a positive number; initializer syntax new LogListener { LogCountFlushLimit = 0 }; copy-pasted defaults.","solutions":["Set a positive value, e.g. listener.LogCountFlushLimit = 100","Validate/replace config values <= 0 with a sane default before assigning","If unbounded buffering is desired, use the listener's flush-timer/API instead of setting the limit to 0"],"exampleFix":"// before\nlistener.LogCountFlushLimit = config.FlushLimit; // may be 0\n// after\nlistener.LogCountFlushLimit = Math.Max(1, config.FlushLimit);","handlingStrategy":"validation","validationCode":"if (limit <= 0) limit = 100; // before: listener.LogCountFlushLimit = limit;","typeGuard":"bool isValidFlushLimit(int v) => v > 0;","tryCatchPattern":"try { listener.LogCountFlushLimit = limit; }\ncatch (ArgumentException) { listener.LogCountFlushLimit = 100; }","preventionTips":["Validate config-sourced limits before assignment","Default to a positive value (e.g. 100)","Never use 0 to mean 'unlimited' with this property"],"tags":["logging","argumentexception","configuration","validation"],"backgroundTag":"invalid-config-value","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}