{"record":{"id":"b283bd080bb3dd4f","repo":"apache/iceberg","slug":"could-not-find-tasks-for-plan-task-s","errorCode":null,"errorMessage":"Could not find tasks for plan task %s","messagePattern":"Could not find tasks for plan task (.+?)","errorType":"exception","errorClass":"NoSuchPlanTaskException","httpStatus":404,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/rest/InMemoryPlanningState.java","lineNumber":115,"sourceCode":"        existingStatus);\n    asyncPlanningStates.put(plan, PlanStatus.COMPLETED);\n  }\n\n  void markAsyncPlanFailed(String plan) {\n    PlanStatus existingStatus = asyncPlanningStates.get(plan);\n    Preconditions.checkArgument(existingStatus != null, \"Cannot find plan %s\", plan);\n    Preconditions.checkArgument(\n        existingStatus == PlanStatus.SUBMITTED,\n        \"Cannot mark plan %s as completed as it is %s\",\n        plan,\n        existingStatus);\n    asyncPlanningStates.put(plan, PlanStatus.FAILED);\n  }\n\n  List<FileScanTask> fileScanTasksForPlanTask(String planTaskKey) {\n    List<FileScanTask> tasks = planTaskToFileScanTasks.get(planTaskKey);\n    if (tasks == null) {\n      throw new NoSuchPlanTaskException(\"Could not find tasks for plan task %s\", planTaskKey);\n    }\n\n    return tasks;\n  }\n\n  List<String> nextPlanTask(String planTaskKey) {\n    String nextPlanTask = planTaskToNext.get(planTaskKey);\n    if (nextPlanTask != null) {\n      return ImmutableList.of(nextPlanTask);\n    }\n\n    return ImmutableList.of();\n  }\n\n  /**\n   * Retrieves the initial set of file scan tasks for a plan. PlanIDs are assumed to be separated\n   * with hyphens where the last component indicates the sequencing of plan IDs.\n   *","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/rest/InMemoryPlanningState.java#L97-L133","documentation":"InMemoryPlanningState maps each plan-task key to its resulting List<FileScanTask>. fileScanTasksForPlanTask throws NoSuchPlanTaskException when the given plan-task key has no entry, i.e. tasks were never registered or were fetched under a wrong key.","triggerScenarios":"Requesting file scan tasks for a plan-task key that was never produced by plan submission; using a truncated/malformed task key; querying tasks before the plan reached COMPLETED status; hitting a different server instance than the one that planned the scan.","commonSituations":"Test harness pagination logic using incorrect next-plan-task keys; clients reading task results from a stale or restarted in-memory server; mixing plan IDs and task keys.","solutions":["Fetch task keys only from the plan status/response objects produced by the same planning session","Wait until the plan status is COMPLETED before fetching file scan tasks","Verify the exact plan-task key string, including sequence-number suffixes","Re-run planning if the in-memory state was reset"],"exampleFix":"// before\nList<FileScanTask> tasks = state.fileScanTasksForPlanTask(rawKey); // key may be wrong\n// after\nPlanStatus st = state.asyncPlanStatus(planId);\nif (st == PlanStatus.COMPLETED) {\n  List<FileScanTask> tasks = state.fileScanTasksForPlanTask(planResponse.nextPlanTask());\n}","handlingStrategy":"try-catch","validationCode":"if (planTaskKey == null || planTaskKey.isEmpty()) throw new IllegalArgumentException(\"plan task key required\");","typeGuard":null,"tryCatchPattern":"try {\n  tasks = planningState.fileScanTasksForPlanTask(taskKey);\n} catch (NoSuchPlanTaskException e) {\n  tasks = List.of(); // or re-plan the scan\n}","preventionTips":["Only use task keys emitted by the same planning session","Fetch tasks only after the plan status is COMPLETED","Avoid hand-building or truncating plan-task key strings","Re-plan if the test server state was reset"],"tags":["rest-catalog","planning","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}