sealosdevbox 沙盒编辑文件时按正则替换,含特殊字符或多行的内容会改错或不修改
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- typescript
- Domain
- backend
Research direction
Start with sdk/sandbox-adapter/src/polyfills/command-filesystem.ts and trace CommandFilesystemPolyfill.replaceContent and readFile. Reproduce the literal, backslash, multiline, and missing-file cases described in the issue; check the linked pull request #8120 for work already underway. Done means replacements preserve the requested text, multiline matches work, and missing files return an error.
Written by the indexing model from the issue text.
Description
使用 sealosdevbox 沙盒时,Agent 的编辑文件工具调用 CommandFilesystemPolyfill.replaceContent,内部执行 sed -i 's/<old>/<new>/g'。oldContent 被当作 sed 正则并按行匹配:
.、*、[、^、$按正则解释,可能匹配不到,或改到其他位置。- 反斜杠被转义为 4 个,sed 查找的是两个反斜杠;
newContent中的单个\写入后变成两个。 - 跨行的
oldContent报错sed: -e expression #1, char 3: unterminated 's' command。 - 未匹配时 sed 返回 0,工具回复编辑成功,文件实际未变。
另外,readFile 在 stat 失败时执行 cat file | base64 -w 0,文件不存在时退出码为 0,读取结果为空内容,而不是 FILE_NOT_FOUND。
复现步骤
- 在 sealosdevbox 沙盒中创建文件,内容为
const re = /a.b*/;。 - 调用编辑文件工具:
oldContent: "/a.b*/",newContent: "/a\\.b+/"。 - 工具返回
Files edited successfully,文件内容未变。
预期行为
oldContent 按字面量匹配,支持多行;替换结果与输入一致;文件不存在时返回错误。
环境
- FastGPT main(749809070b)
- 沙盒提供方:sealosdevbox(
sdk/sandbox-adapter/src/polyfills/command-filesystem.ts)
- Dominant language
- TypeScript
- Stars
- 29.9k
- Forks
- 7.3k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 226
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from labring/FastGPT
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
labring/FastGPT#8141 · 1 comment ·
Maintainers usually reply within 1 day
-
工具调用节点落库的 AI 消息 dataId 与 responseChatItemId 不一致,getResData 按后者查询返回为空Possibly taken @c121914yu claimed this 5 days ago. Openbug
labring/FastGPT#8134 · 2 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
循环节点内无法使用并行节点Possibly taken @mmhh256 claimed this 6 days ago. Openfeature
Difficulty 4/5 3-5 days Newbie friendliness 25/100
labring/FastGPT#8113 · 6 comments ·
Maintainers usually reply within 1 day
-
fastgpt的cpu资源占用非常高Openbug undetermined
Difficulty 4/5 3-5 days Newbie friendliness 35/100
labring/FastGPT#8012 · 1 comment ·
Maintainers usually reply within 1 day
-
4.17.2画布拖动有bugPossibly taken @Nixieboluo claimed this 19 days ago. Openbug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
labring/FastGPT#7948 · 1 assignee ·
Maintainers usually reply within 1 day
Similar issues
-
Add: Disco Mix SDOpencheck:passed streams:add
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
level2 nsoc26
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
GauravKarakoti/SecureFlow#1488 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
deltachat/deltachat-desktop#6914 ·
Maintainers usually reply within 2 days
-
area:cli bug P4
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
bug from-studio
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
esengine/DeepSeek-Reasonix#14868 ·
Maintainers usually reply within 1 day