{"record":{"id":"7568b24089cf46ea","repo":"egametang/ET","slug":"slot-index-slotindex-exceeds-capacity-self-capa-7568b2","errorCode":null,"errorMessage":"slot index {slotIndex} exceeds capacity {self.Capacity}","messagePattern":"slot index (.+?) exceeds capacity (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"Packages/cn.etetet.item/Scripts/Hotfix/Server/ItemComponentSystem.cs","lineNumber":205,"sourceCode":"        {\n            if ((uint)slotIndex < (uint)self.SlotItems.Count)\n            {\n                return self.SlotItems[slotIndex];\n            }\n\n            return null;\n        }\n\n        private static void EnsureSlotIndex(ItemComponent self, int slotIndex)\n        {\n            if (slotIndex < 0)\n            {\n                throw new Exception($\"invalid slot index: {slotIndex}\");\n            }\n\n            if (slotIndex >= self.Capacity)\n            {\n                throw new Exception($\"slot index {slotIndex} exceeds capacity {self.Capacity}\");\n            }\n        }\n\n        private static void EnsureSlotContainerSize(ItemComponent self, int size)\n        {\n            if (size <= 0)\n            {\n                return;\n            }\n\n            if (self.SlotItems.Count >= size)\n            {\n                return;\n            }\n\n            int addCount = size - self.SlotItems.Count;\n            for (int i = 0; i < addCount; ++i)\n            {","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.item/Scripts/Hotfix/Server/ItemComponentSystem.cs#L187-L223","documentation":"Thrown by the SERVER-side ItemComponentSystem.EnsureSlotIndex when slotIndex >= self.Capacity (the second guard, after the negative check). This is the server-side twin of error 200. The server bag defaults to Capacity 100 (Awake, line 17), so any index at or above the current capacity is rejected before writing SlotItems.","triggerScenarios":"Server code calls SetSlotItem with an index that was valid under a larger capacity but the bag was shrunk, or a caller computed an index from a stale/config capacity that exceeds the live Capacity. Also triggered if SetCapacity is never called to grow the bag before placing items beyond the default 100.","commonSituations":"Capacity shrink without re-mapping existing items; a config change lowering the bag size while items still occupy high slots; server logic that assumes a bigger bag than was actually allocated.","solutions":["Grow Capacity via SetCapacity before placing items at higher indices.","When shrinking capacity, first move/evict items in slots >= new Capacity (the code currently never shrinks SlotItems, so a manual remap is required).","Always read self.Capacity at call time rather than caching it."],"exampleFix":"// before\ncomponent.SetSlotItem(115, item); // Capacity still 100\n\n// after\nif (component.Capacity <= 115) component.SetCapacity(120);\ncomponent.SetSlotItem(115, item);","handlingStrategy":"validation","validationCode":"if (slotIndex < 0 || slotIndex >= component.Capacity)\n{\n    Log.Error($\"slot {slotIndex} invalid for capacity {component.Capacity}\");\n    return;\n}\ncomponent.SetSlotItem(slotIndex, item);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Grow Capacity before placing items at higher indices.","When shrinking, remap items out of the truncated range first.","Read self.Capacity live; do not trust a stale cached value."],"tags":["item","server","slot-index","capacity","validation"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}