fix(bootstrap): guard bootstrap name checks against undefined names (… · openclaw/openclaw@25fa46b
zhouhe-xydt
·
2026-05-23
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -103,6 +103,29 @@ describe("analyzeBootstrapBudget", () => {
|
103 | 103 | }); |
104 | 104 | |
105 | 105 | describe("bootstrap prompt warnings", () => { |
| 106 | +it("handles malformed truncation entries without names", () => { |
| 107 | +const analysis = analyzeBootstrapBudget({ |
| 108 | +files: [ |
| 109 | +{ |
| 110 | +name: "TEMP.md", |
| 111 | +path: "/tmp/unknown", |
| 112 | +missing: false, |
| 113 | +rawChars: 10, |
| 114 | +injectedChars: 1, |
| 115 | +truncated: true, |
| 116 | +}, |
| 117 | +], |
| 118 | +bootstrapMaxChars: 5, |
| 119 | +bootstrapTotalMaxChars: 5, |
| 120 | +}); |
| 121 | +(analysis.truncatedFiles[0] as { name?: string }).name = undefined; |
| 122 | + |
| 123 | +const lines = formatBootstrapTruncationWarningLines({ |
| 124 | + analysis, |
| 125 | +}); |
| 126 | +expect(lines.join("\n")).toContain("10 raw -> 1 injected"); |
| 127 | +}); |
| 128 | + |
106 | 129 | it("appends warning details to the turn prompt instead of mutating the system prompt", () => { |
107 | 130 | const prompt = appendBootstrapPromptWarning("Please continue.", [ |
108 | 131 | "AGENTS.md: 200 raw -> 0 injected", |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。