fix(aliyun): give ROS template tools actionable input errors - #206
Open
ruanzhengxin-zhuxing wants to merge 1 commit into
Open
fix(aliyun): give ROS template tools actionable input errors#206ruanzhengxin-zhuxing wants to merge 1 commit into
ruanzhengxin-zhuxing wants to merge 1 commit into
Conversation
ROS template tools (ros_validate_template, ros_get_template_parameter_constraints, ros_preview_template, ros_estimate_template_cost) failed with errors the agent could not act on, so the same failing call was repeated across tools: - An unreadable local template_url surfaced as "body_file is invalid" because _read_body_file raises ApiContractError, which the materialization step did not catch, bypassing the structured ROS1202 preflight diagnostic. These tools have no body_file input, so the error was unactionable. - Missing required inputs collapsed into a generic invalid_tool_input message that did not name the offending field. Now the materialization step maps ApiContractError to the ROS preflight report (with distinct read/UTF-8/size guidance), and delegated input validation reports the missing fields so the public error names parameters/stack_name/template_url and tells the caller to fix the input instead of repeating the same call.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
ROS 模板工具(
ros_validate_template、ros_get_template_parameter_constraints、ros_preview_template、ros_estimate_template_cost)在输入有缺陷时返回的错误无法指导修复,导致 agent 首次失败后在不同工具上重复相同调用(会话证据:93851da3d55542baa2684387d4d5fc31、f608eb3cc8944c95a81e901db47c1b2a、3a0edeb1756b4e4fbf4e40689a1ee928)。根因有两点:
本地
template_url读取失败被误报为body_file is invalid_execute_runtime_unattached的 materialize 阶段通过_read_body_file读取本地模板;该函数把底层OSError包装成ApiContractError("invalid_body_file"),而调用处只捕获(OSError, UnicodeError),因此本应产出的 ROS1202 结构化预检诊断永远不会命中,错误最终渲染为 "body_file is invalid"。这些工具的输入 schema 里没有body_file字段,agent 无法把错误关联到template_url。必填输入缺失只返回泛化
invalid_tool_inputvalidate_delegated_tool_input仅返回 bool,缺parameters/stack_name时错误不指明字段,也不给修复方向。修改
aliyun_api.py:materialize 阶段同时捕获ApiContractError,统一走local_template_source_error,ROS 模板调用不再出现无法处理的body_file错误。hooks/ros_validate.py:ROS1202 诊断区分读取失败 / 非 UTF-8 / 超过大小限制三种情形,并给出对应修复建议。ros_template_tools.py:新增delegated_tool_input_error,返回missing_required_parameters:<names>以点名缺失字段;validate_delegated_tool_input复用它保持兼容。runtime.py/aliyun_api.py:delegated 授权与执行路径改用带字段信息的错误码。public_errors.py:缺失字段消息追加可执行指引(parameters提示先用ros_get_template_parameter_constraints求解合法取值、stack_name说明是工具参数、template_url说明可接受的路径形式),并明确"先修复输入再调用,不要重复相同调用"。测试
template_url不可读时返回 ROS1202(不含body_file),以及缺parameters/stack_name时错误点名字段。tests/tools/cloud/aliyun+tests/i18n:2185 passed。pytest tests/:13277 passed, 4 skipped;另有 2 个失败(test_prepare_direct_binary_installer_reports_invalid_http_url_without_leaking_token、test_latest_pipeline_sidecar_reads_nested_session_layout)在父提交上同样复现,属既有问题。ruff check与ty check src/均通过。