Skip to content

refactor(layer): use structured BindPath type instead of string[]#421

Merged
leavesster merged 1 commit intomainfrom
refactor/layer-bindpaths-type
Jan 30, 2026
Merged

refactor(layer): use structured BindPath type instead of string[]#421
leavesster merged 1 commit intomainfrom
refactor/layer-bindpaths-type

Conversation

@leavesster
Copy link
Contributor

Summary

  • Replace bind_paths?: string[] with bindPaths?: BindPath[] in createPackageLayer
  • Remove redundant bindPathPattern regex validation
  • Use the same conversion logic as buildRunConfigArgs in oocana.ts

Test plan

  • pnpm build passes
  • pnpm test passes

Align createPackageLayer with the BindPath type already defined in
oocana.ts, removing redundant string validation regex and using the
same conversion logic as buildRunConfigArgs.
Copilot AI review requested due to automatic review settings January 30, 2026 09:15
@coderabbitai
Copy link

coderabbitai bot commented Jan 30, 2026

Summary by CodeRabbit

发布说明

  • 破坏性变更
    • 绑定路径配置 API 已更新。新版本采用结构化配置方式替代原有的字符串格式,提供更灵活的挂载选项设置和更清晰的配置结构。

✏️ Tip: You can customize this high-level summary in your review settings.

总体概览

此拉取请求对绑定路径配置API进行了重构,将基于字符串的参数 bind_paths 更新为基于对象数组的 bindPaths,包含 srcdst 属性,并支持可选的 moderecursive 配置选项。

变更详情

内聚组 / 文件 变更摘要
绑定路径API重构
packages/oocana/src/layer.ts, flow-examples/test/layer.test.ts
bind_paths?: string[] 参数更新为 bindPaths?: Array<{ src: string; dst: string }> 对象数组。移除字符串验证正则表达式,改为从对象属性(srcdstmoderecursive)构建绑定路径字符串。更新测试用例以适配新的API调用方式。

估计代码审查工作量

🎯 2 (Simple) | ⏱️ ~10 分钟

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed 标题完全符合要求的格式 <type>(<scope>): <subject>,且准确概括了主要变更:将字符串数组替换为结构化的BindPath类型。
Description check ✅ Passed 描述与变更集完全相关,清晰列出了主要修改内容(替换bind_paths为bindPaths、移除bindPathPattern、使用相同的转换逻辑)并包含测试计划。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@leavesster leavesster enabled auto-merge (squash) January 30, 2026 09:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the createPackageLayer function to use a structured BindPath type instead of string arrays for bind path configuration, improving type safety and consistency with the existing buildRunConfigArgs function.

Changes:

  • Replaced bind_paths?: string[] parameter with bindPaths?: BindPath[] in createPackageLayer
  • Removed redundant bindPathPattern regex validation and non-functional error message
  • Implemented the same structured-to-string conversion logic used in buildRunConfigArgs

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/oocana/src/layer.ts Updated createPackageLayer to accept BindPath[] type and use structured conversion logic matching buildRunConfigArgs
flow-examples/test/layer.test.ts Updated test to use the new structured BindPath object format instead of string format

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@packages/oocana/src/layer.ts`:
- Around line 74-83: The current loop that builds bind-path strings from
bindPaths (using bind.src, bind.dst, bind.mode, bind.recursive and then
args.push("--bind-paths", path)) can produce ambiguous CLI args when src/dst
contain ',' or '='; replace the ad-hoc comma/equal concatenation with a robust,
unambiguous encoding: validate bind.src and bind.dst for emptiness, then
serialize the entire bind object (e.g., JSON.stringify(bind) or base64 of the
JSON) and pass that single encoded string to args.push("--bind-paths",
<encoded>); update the consumer that parses the flag to decode the same format,
or alternatively explicitly reject src/dst that contain ',' or '=' with a clear
error message to avoid ambiguous parsing.

Comment on lines +74 to 83
for (const bind of bindPaths ?? []) {
let path = `src=${bind.src},dst=${bind.dst}`;
if (bind.mode) {
path += `,${bind.mode}`;
}
if (bind.recursive !== undefined) {
path += `,${bind.recursive ? "recursive" : "nonrecursive"}`;
}

args.push("--bind-paths", path);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

建议校验 src/dst 中的分隔符,避免 CLI 解析歧义。
当前拼接格式基于逗号与等号分隔,若路径包含这些字符会导致参数被错误拆分。

建议修复
 for (const bind of bindPaths ?? []) {
+  if (/[=,]/.test(bind.src) || /[=,]/.test(bind.dst)) {
+    throw new Error("bindPaths src/dst 不能包含 ',' 或 '='");
+  }
   let path = `src=${bind.src},dst=${bind.dst}`;
   if (bind.mode) {
     path += `,${bind.mode}`;
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
for (const bind of bindPaths ?? []) {
let path = `src=${bind.src},dst=${bind.dst}`;
if (bind.mode) {
path += `,${bind.mode}`;
}
if (bind.recursive !== undefined) {
path += `,${bind.recursive ? "recursive" : "nonrecursive"}`;
}
args.push("--bind-paths", path);
}
for (const bind of bindPaths ?? []) {
if (/[=,]/.test(bind.src) || /[=,]/.test(bind.dst)) {
throw new Error("bindPaths src/dst 不能包含 ',' 或 '='");
}
let path = `src=${bind.src},dst=${bind.dst}`;
if (bind.mode) {
path += `,${bind.mode}`;
}
if (bind.recursive !== undefined) {
path += `,${bind.recursive ? "recursive" : "nonrecursive"}`;
}
args.push("--bind-paths", path);
}
🤖 Prompt for AI Agents
In `@packages/oocana/src/layer.ts` around lines 74 - 83, The current loop that
builds bind-path strings from bindPaths (using bind.src, bind.dst, bind.mode,
bind.recursive and then args.push("--bind-paths", path)) can produce ambiguous
CLI args when src/dst contain ',' or '='; replace the ad-hoc comma/equal
concatenation with a robust, unambiguous encoding: validate bind.src and
bind.dst for emptiness, then serialize the entire bind object (e.g.,
JSON.stringify(bind) or base64 of the JSON) and pass that single encoded string
to args.push("--bind-paths", <encoded>); update the consumer that parses the
flag to decode the same format, or alternatively explicitly reject src/dst that
contain ',' or '=' with a clear error message to avoid ambiguous parsing.

@leavesster leavesster merged commit 0870924 into main Jan 30, 2026
18 of 20 checks passed
@leavesster leavesster deleted the refactor/layer-bindpaths-type branch January 30, 2026 09:30
@oomol-bot oomol-bot mentioned this pull request Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments