-
Notifications
You must be signed in to change notification settings - Fork 34
fix(server): forward plan fleet overrides for task routes #397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -107,6 +107,11 @@ def executor(task_info: Any) -> list[dict[str, Any]]: | |||||||||||||||||||
| else: | ||||||||||||||||||||
| raise ValueError('必须提供 plan 或 plan_id') | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # 允许 plan_id + plan 覆盖: 前端可在不改 YAML 的情况下动态指定舰队与舰船名单。 | ||||||||||||||||||||
| request_plan = request.plan | ||||||||||||||||||||
| override_fleet_id = request_plan.fleet_id if request_plan is not None else None | ||||||||||||||||||||
| override_fleet = request_plan.fleet if request_plan is not None else None | ||||||||||||||||||||
|
|
||||||||||||||||||||
| for i in range(request.times): | ||||||||||||||||||||
| if task_manager.should_stop(): | ||||||||||||||||||||
| break | ||||||||||||||||||||
|
|
@@ -115,7 +120,13 @@ def executor(task_info: Any) -> list[dict[str, Any]]: | |||||||||||||||||||
| _log.info('[Task] 常规战第 {}/{} 轮', i + 1, request.times) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| try: | ||||||||||||||||||||
| result = run_normal_fight(ctx, plan, times=1)[0] | ||||||||||||||||||||
| result = run_normal_fight( | ||||||||||||||||||||
| ctx, | ||||||||||||||||||||
| plan, | ||||||||||||||||||||
| times=1, | ||||||||||||||||||||
| fleet_id=override_fleet_id, | ||||||||||||||||||||
| fleet=override_fleet, | ||||||||||||||||||||
| )[0] | ||||||||||||||||||||
| results.append(convert_combat_result(result, i + 1)) | ||||||||||||||||||||
| task_manager.add_result(results[-1]) | ||||||||||||||||||||
| except Exception as e: | ||||||||||||||||||||
|
|
@@ -152,7 +163,15 @@ def executor(task_info: Any) -> list[dict[str, Any]]: | |||||||||||||||||||
| else: | ||||||||||||||||||||
| raise ValueError('必须提供 plan 或 plan_id') | ||||||||||||||||||||
|
|
||||||||||||||||||||
| fleet_id = request.fleet_id or plan.fleet_id | ||||||||||||||||||||
| request_plan = request.plan | ||||||||||||||||||||
| override_fleet = request_plan.fleet if request_plan is not None else None | ||||||||||||||||||||
| # 优先级: 顶层 fleet_id > plan 覆盖 fleet_id > YAML 内 fleet_id | ||||||||||||||||||||
| if request.fleet_id is not None: | ||||||||||||||||||||
| fleet_id = request.fleet_id | ||||||||||||||||||||
| elif request_plan is not None and request_plan.fleet_id is not None: | ||||||||||||||||||||
|
Comment on lines
+168
to
+171
|
||||||||||||||||||||
| # 优先级: 顶层 fleet_id > plan 覆盖 fleet_id > YAML 内 fleet_id | |
| if request.fleet_id is not None: | |
| fleet_id = request.fleet_id | |
| elif request_plan is not None and request_plan.fleet_id is not None: | |
| plan_fleet_id_is_set = request_plan is not None and 'fleet_id' in request_plan.model_fields_set | |
| # 优先级: 顶层 fleet_id > plan 显式覆盖 fleet_id > YAML 内 fleet_id | |
| if request.fleet_id is not None: | |
| fleet_id = request.fleet_id | |
| elif plan_fleet_id_is_set: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CombatPlanRequest.fleet_idhas a default of1(non-optional). When the client sendsplan_id+ a partialplanonly to overridefleet(or other fields),request_plan.fleet_idwill still be1, so this will unintentionally override the YAML plan’sfleet_idto1by passingfleet_id=override_fleet_idintorun_normal_fight. Consider treating fleet overrides as “only if explicitly provided”, e.g. derive overrides fromrequest_plan.model_fields_set/exclude_unset=Trueand passfleet_id=Noneunlessfleet_idwas actually included in the request payload.