{"record":{"id":"abcdae170c72939d","repo":"stride3d/stride","slug":"the-queue-is-empty","errorCode":null,"errorMessage":"The queue is empty","messagePattern":"The queue is empty","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Yaml/InsertionQueue.cs","lineNumber":82,"sourceCode":"\n        /// <summary>\n        /// Enqueues the specified item.\n        /// </summary>\n        /// <param name=\"item\">The item to be enqueued.</param>\n        public void Enqueue(T item)\n        {\n            items.Add(item);\n        }\n\n        /// <summary>\n        /// Dequeues an item.\n        /// </summary>\n        /// <returns>Returns the item that been dequeued.</returns>\n        public T Dequeue()\n        {\n            if (Count == 0)\n            {\n                throw new InvalidOperationException(\"The queue is empty\");\n            }\n\n            T item = items[0];\n            items.RemoveAt(0);\n            return item;\n        }\n\n        /// <summary>\n        /// Inserts an item at the specified index.\n        /// </summary>\n        /// <param name=\"index\">The index where to insert the item.</param>\n        /// <param name=\"item\">The item to be inserted.</param>\n        public void Insert(int index, T item)\n        {\n            items.Insert(index, item);\n        }\n    }\n}","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Yaml/InsertionQueue.cs#L64-L100","documentation":"InsertionQueue<T>.Dequeue removes and returns the front item; when Count is 0 there is nothing to return, so it throws InvalidOperationException. This is a usage-contract violation: callers must only dequeue when the queue is non-empty.","triggerScenarios":"Calling Dequeue() on an InsertionQueue<T> with Count == 0 — e.g. dequeuing in a loop without checking Count, or dequeuing more times than items were enqueued.","commonSituations":"Event-queue draining loops in YAML processing that don't check emptiness, off-by-one in consumer/producer counts, re-entrancy draining the same queue twice.","solutions":["Check queue.Count > 0 before calling Dequeue()","Guard the drain loop with while (queue.Count > 0) instead of a fixed iteration count","Wrap in try/catch (InvalidOperationException) if emptiness is an expected boundary condition"],"exampleFix":"// before\nwhile (true) { var item = queue.Dequeue(); ... }\n// after\nwhile (queue.Count > 0) { var item = queue.Dequeue(); ... }","handlingStrategy":"validation","validationCode":"if (queue.Count == 0) return default; // or skip\nvar item = queue.Dequeue();","typeGuard":null,"tryCatchPattern":"try { var item = queue.Dequeue(); } catch (InvalidOperationException) { /* queue was empty */ }","preventionTips":["Always check Count before Dequeue","Drain with while (queue.Count > 0)","Track enqueue/dequeue balance in loops"],"tags":["yaml","queue","invalid-operation","empty-collection"],"backgroundTag":"empty-result-set","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"}