AzurLaneAutoScript icon indicating copy to clipboard operation
AzurLaneAutoScript copied to clipboard

岛屿店铺购买材料时发生 TypeError

Open XDista opened this issue 1 month ago • 4 comments

在提问之前...

  • [x] 我已经搜索了现有的 issues
  • [x] 我在提问题之前至少花费了 5 分钟来思考和准备
  • [x] 我已经阅读了 Wiki 中的 常见问题(FAQ)
  • [x] 我正在使用最新版的 Alas

描述你的问题

运行"岛屿生产"功能时,在 Dispatch Production 阶段,程序尝试为"丰壤农田 (101)"派遣生产后,前往店铺购买"小麦种子"时发生崩溃。

如何复现

1.运行 岛屿生产 任务 2.当有生产槽位空缺需要派遣时,程序自动进入店铺购买材料 3.进入的店铺页面中商品数量少于 OCR 检测的槽位总数 4.程序在 5 秒超时后崩溃抛出 TypeError (3和4为AI分析结果)

预期行为

程序应能正确处理空槽位并购买商品

相关 Logs

见附件

截图

error.txt

还有别的吗?

No response

XDista avatar Oct 19 '26 13:10 XDista

日版一樣問題

2026-10-19 20:55:28.181 | INFO | [island_shop_item_name_ocr 0.331s] ['小麦の種', 'とうもろこしの', '陸稲の種',         
'白菜の種', 'じゃがいもの種', '大豆の種', '牧草の種', 'コーヒ一の木の', '', '', '', '']                                
2026-10-19 20:55:28.185 | INFO | Corrected 'とうもろこしの' to 'とうもろこしの種' with distance 0                      
2026-10-19 20:55:28.189 | INFO | Corrected 'コーヒ一の木の' to 'コーヒーの木の種' with distance 1                      
2026-10-19 20:55:28.190 | WARNING | Failed to recognize some item names: ['小麦の種', 'とうもろこしの', '陸稲の種',    
'白菜の種', 'じゃがいもの種', '大豆の種', '牧草の種', 'コーヒ一の木の', '', '', '', ''], ids: [411000, 411001, 411002, 
411003, 411005, 411006, 411008, 411009, None, None, None, None]                                                        
2026-10-19 20:55:28.193 | ERROR | TypeError: zip argument #1 must support iteration                                    
┌───────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────┐
│                                                                                                                     │
│ D:\AzurLaneAutoScript\alas.py:69 in run                                                                             │
│                                                                                                                     │
│    66 │   │   try:                                                                                                  │
│    67 │   │   │   if not skip_first_screenshot:                                                                     │
│    68 │   │   │   │   self.device.screenshot()                                                                      │
│ >  69 │   │   │   self.__getattribute__(command)()                                                                  │
│    70 │   │   │   return True                                                                                       │
│    71 │   │   except TaskEnd:                                                                                       │
│    72 │   │   │   return True                                                                                       │
│                                                                                                                     │
│ ┌──────────────────────────────────── locals ────────────────────────────────────┐                                  │
│ │               command = 'island_production'                                    │                                  │
│ │                     e = TypeError('zip argument #1 must support iteration')    │                                  │
│ │                  self = <alas.AzurLaneAutoScript object at 0x0000015592C266C8> │                                  │
│ │ skip_first_screenshot = False                                                  │                                  │
│ └────────────────────────────────────────────────────────────────────────────────┘                                  │
│ D:\AzurLaneAutoScript\alas.py:416 in island_production                                                              │
│                                                                                                                     │
│   413 │                                                                                                             │
│   414 │   def island_production(self):                                                                              │
│   415 │   │   from module.island.production import IslandProduction                                                 │
│ > 416 │   │   IslandProduction(config=self.config, device=self.device).run()                                        │
│   417 │                                                                                                             │
│   418 │   def island_order(self):                                                                                   │
│   419 │   │   from module.island.order import IslandOrder                                                           │
│                                                                                                                     │
│ ┌───────────────────────────────── locals ──────────────────────────────────┐                                       │
│ │ IslandProduction = <class 'module.island.production.IslandProduction'>    │                                       │
│ │             self = <alas.AzurLaneAutoScript object at 0x0000015592C266C8> │                                       │
│ └───────────────────────────────────────────────────────────────────────────┘                                       │
│                                                                                                                     │
│ D:\AzurLaneAutoScript\module\island\production.py:342 in run                                                        │
│                                                                                                                     │
│   339 │   │   if not yaml_text or yaml_text == "{}":                                                                │
│   340 │   │   │   logger.critical('No daily buffer items found in config, please run Island                         │
│       Production Planner first')                                                                                    │
│   341 │   │   │   raise RequestHumanTakeover('No daily buffer items found in config, please                         │
│       run Island Production Planner first')                                                                         │
│ > 342 │   │   self.dispatch_all()                                                                                   │
│   343 │   │   next_run_time = list(self.slot_finish_time.values())                                                  │
│   344 │   │   with self.config.multi_set():                                                                         │
│   345 │   │   │   sorted_items = sorted(self.slot_finish_time.items(), key=lambda kv: (kv[1],                       │
│       kv[0]))                                                                                                       │
│                                                                                                                     │
│ ┌──────────────────────────────────────────────────── locals ─────────────────────────────────────────────────────┐ │
│ │             self = <module.island.production.IslandProduction object at 0x00000155D2D4F588>                     │ │
│ │ slot_finish_time = {}                                                                                           │ │
│ │        yaml_text = '小麦 (2000): 2802\nとうもろこし (2001): 260\n白菜 (2003): 27\nニンジン (2004): 3\n大豆      │ │
│ │                    (2006): 419\n牧'+528                                                                         │ │
│ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ │
│                                                                                                                     │
│ D:\AzurLaneAutoScript\module\island\production.py:298 in dispatch_all                                               │
│                                                                                                                     │
│   295 │   │   │   try:                                                                                              │
│   296 │   │   │   │   for place_id in self.slot_grids.keys():                                                       │
│   297 │   │   │   │   │   if place_id not in dispatched_places:                                                     │
│ > 298 │   │   │   │   │   │   self.dispatch_place(place_id)                                                         │
│   299 │   │   │   │   │   │   dispatched_places.add(place_id)                                                       │
│   300 │   │   │   │   if not self.next_page():                                                                      │
│   301 │   │   │   │   │   break                                                                                     │
│                                                                                                                     │
│ ┌─────────────────────────────────────────── locals ───────────────────────────────────────────┐                    │
│ │ dispatched_places = set()                                                                    │                    │
│ │          place_id = 101                                                                      │                    │
│ │              self = <module.island.production.IslandProduction object at 0x00000155D2D4F588> │                    │
│ └──────────────────────────────────────────────────────────────────────────────────────────────┘                    │
│                                                                                                                     │
│ D:\AzurLaneAutoScript\module\island\production.py:283 in dispatch_place                                             │
│                                                                                                                     │
│   280 │   │   │   │   logger.info(f'No more recipe for {place}, skip remaining slots')                              │
│   281 │   │   │   │   break                                                                                         │
│   282 │   │   │   if self.is_slot_empty(slot_button):                                                               │
│ > 283 │   │   │   │   self.dispatch_slot(slot_id=slot_id, slot_button=slot_button,                                  │
│       worker='manjuu')                                                                                              │
│   284 │   │   │   if is_first:                                                                                      │
│   285 │   │   │   │   is_first = False                                                                              │
│   286 │   │   del_cached_property(super(), 'recipe_id_sequence')                                                    │
│                                                                                                                     │
│ ┌──────────────────────────────────────── locals ────────────────────────────────────────┐                          │
│ │   __class__ = <class 'module.island.production.IslandProduction'>                      │                          │
│ │    is_first = True                                                                     │                          │
│ │       place = '豊穣の畑 (101)'                                                         │                          │
│ │    place_id = 101                                                                      │                          │
│ │        self = <module.island.production.IslandProduction object at 0x00000155D2D4F588> │                          │
│ │ slot_button = 101_SLOT_GRID_0_0                                                        │                          │
│ │   slot_grid = <module.base.button.ButtonGrid object at 0x00000155D2E97788>             │                          │
│ │     slot_id = 9001                                                                     │                          │
│ └────────────────────────────────────────────────────────────────────────────────────────┘                          │
│                                                                                                                     │
│ D:\AzurLaneAutoScript\module\island\production.py:252 in dispatch_slot                                              │
│                                                                                                                     │
│   249 │   │   if worker == 'manjuu':                                                                                │
│   250 │   │   │   self.island_dock_select_manjuu()                                                                  │
│   251 │   │   self.island_dock_select_confirm(self.is_in_recipe_menu)                                               │
│ > 252 │   │   target_time = super().run(slot_id=slot_id)                                                            │
│   253 │   │   if target_time is not None:                                                                           │
│   254 │   │   │   target_time = target_time.replace(microsecond=0)                                                  │
│   255 │   │   │   self.slot_finish_time[slot_id] = target_time                                                      │
│                                                                                                                     │
│ ┌──────────────────────────────────────── locals ────────────────────────────────────────┐                          │
│ │   __class__ = <class 'module.island.production.IslandProduction'>                      │                          │
│ │           _ = array([[[ 41,  73,  66],                                                 │                          │
│ │               │   │   [ 41,  77,  74],                                                 │                          │
│ │               │   │   [ 41,  73,  66],                                                 │                          │
│ │               │   │   ...,                                                             │                          │
│ │               │   │   [ 33,  81, 107],                                                 │                          │
│ │               │   │   [ 33,  77, 107],                                                 │                          │
│ │               │   │   [ 33,  81, 107]],                                                │                          │
│ │               │                                                                        │                          │
│ │               │      [[ 41,  77,  74],                                                 │                          │
│ │               │   │   [ 41,  77,  66],                                                 │                          │
│ │               │   │   [ 41,  77,  74],                                                 │                          │
│ │               │   │   ...,                                                             │                          │
│ │               │   │   [ 33,  77, 107],                                                 │                          │
│ │               │   │   [ 33,  81, 107],                                                 │                          │
│ │               │   │   [ 33,  81, 107]],                                                │                          │
│ │               │                                                                        │                          │
│ │               │      [[ 41,  73,  66],                                                 │                          │
│ │               │   │   [ 41,  77,  74],                                                 │                          │
│ │               │   │   [ 41,  73,  66],                                                 │                          │
│ │               │   │   ...,                                                             │                          │
│ │               │   │   [ 33,  81, 107],                                                 │                          │
│ │               │   │   [ 33,  77,  99],                                                 │                          │
│ │               │   │   [ 33,  81, 107]],                                                │                          │
│ │               │                                                                        │                          │
│ │               │      ...,                                                              │                          │
│ │               │                                                                        │                          │
│ │               │      [[ 91, 130, 148],                                                 │                          │
│ │               │   │   [ 91, 130, 148],                                                 │                          │
│ │               │   │   [ 91, 134, 148],                                                 │                          │
│ │               │   │   ...,                                                             │                          │
│ │               │   │   [ 25,  69,  25],                                                 │                          │
│ │               │   │   [ 25,  73,  25],                                                 │                          │
│ │               │   │   [ 25,  73,  25]],                                                │                          │
│ │               │                                                                        │                          │
│ │               │      [[ 91, 130, 148],                                                 │                          │
│ │               │   │   [ 91, 134, 157],                                                 │                          │
│ │               │   │   [ 91, 130, 148],                                                 │                          │
│ │               │   │   ...,                                                             │                          │
│ │               │   │   [ 25,  73,  25],                                                 │                          │
│ │               │   │   [ 25,  69,  25],                                                 │                          │
│ │               │   │   [ 25,  73,  25]],                                                │                          │
│ │               │                                                                        │                          │
│ │               │      [[ 91, 134, 148],                                                 │                          │
│ │               │   │   [ 91, 130, 148],                                                 │                          │
│ │               │   │   [ 91, 130, 148],                                                 │                          │
│ │               │   │   ...,                                                             │                          │
│ │               │   │   [ 25,  69,  25],                                                 │                          │
│ │               │   │   [ 25,  73,  25],                                                 │                          │
│ │               │   │   [ 25,  69,  25]]], dtype=uint8)                                  │                          │
│ │        self = <module.island.production.IslandProduction object at 0x00000155D2D4F588> │                          │
│ │ slot_button = 101_SLOT_GRID_0_0                                                        │                          │
│ │     slot_id = 9001                                                                     │                          │
│ │      worker = 'manjuu'                                                                 │                          │
│ └────────────────────────────────────────────────────────────────────────────────────────┘                          │
│                                                                                                                     │
│ D:\AzurLaneAutoScript\module\island_handler\recipe.py:921 in run                                                    │
│                                                                                                                     │
│   918 │   │   │   if batch_count > production_limit:                                                                │
│   919 │   │   │   │   logger.info(f"Will try to run {production_limit} batches")                                    │
│   920 │   │   │   │   batch_count = production_limit                                                                │
│ > 921 │   │   │   result = self.run_recipe(recipe_id, batch_count, mode=mode)                                       │
│   922 │   │   │   if result is not None:                                                                            │
│   923 │   │   │   │   remain_time, real_count = result                                                              │
│   924 │   │   │   │   target_time = datetime.now() + remain_time                                                    │
│                                                                                                                     │
│ ┌──────────────────────────────────────────────────── locals ─────────────────────────────────────────────────────┐ │
│ │         batch_count = 2                                                                                         │ │
│ │                info = RecipeInfo(stock=6488, target_stock=0, daily_buffer=0, batch_size=243, demand=[],         │ │
│ │                       idle_accumulating=2747.187)                                                               │ │
│ │                mode = 'idle_accumulating'                                                                       │ │
│ │    production_limit = 5                                                                                         │ │
│ │           recipe_id = 101007                                                                                    │ │
│ │              result = None                                                                                      │ │
│ │                self = <module.island.production.IslandProduction object at 0x00000155D2D4F588>                  │ │
│ │             slot_id = 9001                                                                                      │ │
│ │            strategy = 'idle_accumulating'                                                                       │ │
│ │ unavailable_product = 2000                                                                                      │ │
│ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ │
│                                                                                                                     │
│ D:\AzurLaneAutoScript\module\island_handler\recipe.py:831 in run_recipe                                             │
│                                                                                                                     │
│   828 │   │   success, real_count = self.prepare_ingredients(                                                       │
│   829 │   │   │   recipe_id,                                                                                        │
│   830 │   │   │   batch_count=batch_count,                                                                          │
│ > 831 │   │   │   mode=mode,                                                                                        │
│   832 │   │   )                                                                                                     │
│   833 │   │   if real_count <= 0:                                                                                   │
│   834 │   │   │   logger.warning(                                                                                   │
│                                                                                                                     │
│ ┌──────────────────────────────────────── locals ────────────────────────────────────────┐                          │
│ │ batch_count = 2                                                                        │                          │
│ │        mode = 'idle_accumulating'                                                      │                          │
│ │   recipe_id = 101007                                                                   │                          │
│ │        self = <module.island.production.IslandProduction object at 0x00000155D2D4F588> │                          │
│ └────────────────────────────────────────────────────────────────────────────────────────┘                          │
│                                                                                                                     │
│ D:\AzurLaneAutoScript\module\island_handler\recipe.py:749 in prepare_ingredients                                    │
│                                                                                                                     │
│   746 │   │   │   │   │   │   self.goto_ingredient_shop_page(entrance_button=button)                                │
│   747 │   │   │   │   │   │   isolated = True                                                                       │
│   748 │   │   │   │   │   delta = real_count * counter[1] - available_stock                                         │
│ > 749 │   │   │   │   │   buy_success = super().island_shop_buy({ingredient_key: delta},                            │
│       isolated=isolated)                                                                                            │
│   750 │   │   │   │   │   success = buy_success and success                                                         │
│   751 │   │   │   │   │   if not isolated:                                                                          │
│   752 │   │   │   │   │   │   # We need an exception for inherited class to handle ui switch                        │
│                                                                                                                     │
│ ┌──────────────────────────────────────────────────── locals ─────────────────────────────────────────────────────┐ │
│ │           __class__ = <class 'module.island_handler.recipe.IslandRecipe'>                                       │ │
│ │     available_stock = 0                                                                                         │ │
│ │         batch_count = 2                                                                                         │ │
│ │ buffer_surplus_mode = False                                                                                     │ │
│ │              button = RECIPE_INGREDIENT_GRID_0_0                                                                │ │
│ │             counter = (0, 9, -9)                                                                                │ │
│ │            counters = [(0, 9, -9)]                                                                              │ │
│ │  daily_buffer_items = {                                                                                         │ │
│ │                       │   2000: 2802,                                                                           │ │
│ │                       │   2001: 260,                                                                            │ │
│ │                       │   2003: 27,                                                                             │ │
│ │                       │   2004: 3,                                                                              │ │
│ │                       │   2006: 419,                                                                            │ │
│ │                       │   2008: 335,                                                                            │ │
│ │                       │   2009: 13,                                                                             │ │
│ │                       │   2011: 12,                                                                             │ │
│ │                       │   2016: 19,                                                                             │ │
│ │                       │   2017: 19,                                                                             │ │
│ │                       │   ... +26                                                                               │ │
│ │                       }                                                                                         │ │
│ │               delta = 18                                                                                        │ │
│ │    failed_buy_items = set()                                                                                     │ │
│ │ get_available_stock = <function IslandRecipe.prepare_ingredients.<locals>.get_available_stock at                │ │
│ │                       0x00000155D3458048>                                                                       │ │
│ │    hard_floor_items = {}                                                                                        │ │
│ │  ingredient_buttons = [RECIPE_INGREDIENT_GRID_0_0]                                                              │ │
│ │     ingredient_grid = <module.base.button.ButtonGrid object at 0x00000155D3470248>                              │ │
│ │      ingredient_key = 1005                                                                                      │ │
│ │            isolated = True                                                                                      │ │
│ │                mode = 'idle_accumulating'                                                                       │ │
│ │     protected_stock = 0                                                                                         │ │
│ │          real_count = 2                                                                                         │ │
│ │         recipe_cost = {1005: 9}                                                                                 │ │
│ │           recipe_id = 101007                                                                                    │ │
│ │       reserve_items = {                                                                                         │ │
│ │                       │   3012: 6,                                                                              │ │
│ │                       │   3101: 6,                                                                              │ │
│ │                       │   4010: 6,                                                                              │ │
│ │                       │   3018: 6,                                                                              │ │
│ │                       │   3104: 6,                                                                              │ │
│ │                       │   4013: 6,                                                                              │ │
│ │                       │   4014: 6,                                                                              │ │
│ │                       │   3009: 5,                                                                              │ │
│ │                       │   3024: 5,                                                                              │ │
│ │                       │   3029: 5,                                                                              │ │
│ │                       │   ... +2                                                                                │ │
│ │                       }                                                                                         │ │
│ │                self = <module.island.production.IslandProduction object at 0x00000155D2D4F588>                  │ │
│ │             success = True                                                                                      │ │
│ │   task_target_items = {}                                                                                        │ │
│ │ task_target_reserve = 0                                                                                         │ │
│ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ │
│                                                                                                                     │
│ D:\AzurLaneAutoScript\module\island_handler\shop.py:281 in island_shop_buy                                          │
│                                                                                                                     │
│   278 │   │   │   │   f'{shop_recipe_name_with_id(recipe_id)} with buy count {buy_count}'                           │
│   279 │   │   │   )                                                                                                 │
│   280 │   │   │   if self.island_shop_set_navbar_and_tab(recipe_id, isolated=isolated):                             │
│ > 281 │   │   │   │   if not self.island_shop_buy_in_page(recipe_id, buy_count):                                    │
│   282 │   │   │   │   │   logger.warning(f'Failed to buy                                                            │
│       {shop_recipe_name_with_id(recipe_id)}')                                                                       │
│   283 │   │   │   │   │   success = False                                                                           │
│   284 │   │   │   else:                                                                                             │
│                                                                                                                     │
│ ┌───────────────────────────────────────── locals ─────────────────────────────────────────┐                        │
│ │        amount = 18                                                                       │                        │
│ │     buy_count = 18                                                                       │                        │
│ │      isolated = True                                                                     │                        │
│ │       item_id = 1005                                                                     │                        │
│ │     recipe_id = 411005                                                                   │                        │
│ │          self = <module.island.production.IslandProduction object at 0x00000155D2D4F588> │                        │
│ │ shopping_dict = {1005: 18}                                                               │                        │
│ │       success = True                                                                     │                        │
│ └──────────────────────────────────────────────────────────────────────────────────────────┘                        │
│                                                                                                                     │
│ D:\AzurLaneAutoScript\module\island_handler\shop.py:190 in island_shop_buy_in_page                                  │
│                                                                                                                     │
│   187 │   │   │   │   f'{shop_recipe_name_with_id(recipe_id)}'                                                      │
│   188 │   │   │   )                                                                                                 │
│   189 │   │   │   return False                                                                                      │
│ > 190 │   │   for id, button in zip(self.island_shop_item_ids,                                                      │
│       self._island_shop_item_grid.buttons):                                                                         │
│   191 │   │   │   if id == recipe_id:                                                                               │
│   192 │   │   │   │   self.island_shop_buy_execute(button, amount)                                                  │
│   193 │   │   │   │   return True                                                                                   │
│                                                                                                                     │
│ ┌────────────────────────────────────────── locals ──────────────────────────────────────────┐                      │
│ │          amount = 18                                                                       │                      │
│ │ currency_amount = 2975                                                                     │                      │
│ │     currency_id = 1                                                                        │                      │
│ │       recipe_id = 411005                                                                   │                      │
│ │        required = 360                                                                      │                      │
│ │            self = <module.island.production.IslandProduction object at 0x00000155D2D4F588> │                      │
│ └────────────────────────────────────────────────────────────────────────────────────────────┘                      │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
TypeError: zip argument #1 must support iteration                                                                      
2026-10-19 20:55:29.068 | WARNING | Saving error: ./log/error/1792414529068                                            
2026-10-19 20:55:29.679 | INFO | No provider specified, skip sending                                                   
2026-10-19 20:57:12.838 | INFO | Electron detected, remove log output to stdout               

ricky469469 avatar Oct 19 '26 13:10 ricky469469

看起来这是今天更新后 island_shop_get_item_ids() 引入的回归问题。

当前逻辑里,item_name_to_recipe_id('') 会对空商品槽返回 None,但 island_shop_get_item_ids() 又把任何 None 都视为 OCR 识别失败: ids = [self.item_name_to_recipe_id(name) for name in names]if any(id is None for id in ids): ... continue

因此只要商店商品数量少于 12 个、存在正常的空槽位,就会一直重试。5 秒超时后该函数没有返回值,最终 self.island_shop_item_ids 变成 None,随后这里: zip(self.island_shop_item_ids, self._island_shop_item_grid.buttons)

就会触发: TypeError: zip argument #1 must support iteration

所以感觉这里看起来不是商品名称 OCR 本身失败,而是正常空槽位产生的 None 被当成 OCR 失败处理了。推测是最近这段商店识别重试逻辑带来的 regression。

dongfengNrq avatar Oct 19 '26 14:10 dongfengNrq

这边发生同样的问题

Jinbo-Wu avatar Oct 19 '26 15:10 Jinbo-Wu

似乎是这个改动导致的: Fix#6062

Capital-Grin avatar Oct 19 '26 16:10 Capital-Grin