MergeSettings leaks raw __merge append annotations into settings.json when settings.system.json has no hooks key
Maintainer thường phản hồi trong vòng 5 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 82/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- bun, typescript
- Lĩnh vực
- backend
Hướng nghiên cứu
Đọc LifeOS/install/LIFEOS/TOOLS/MergeSettings.ts, đặc biệt là mergeSettings() quanh dòng 187, và tái hiện trường hợp hooks chỉ có trong overlay bằng probe được cung cấp. Xác nhận rằng chú thích append trở thành một mảng khi hooks không có trong cài đặt hệ thống; hoàn tất khi probe chạy thành công và settings.json được tạo có các mảng cho những sự kiện hook.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Version
LifeOS 8.761.0. The buggy line is present in v8.761.0 and in current main (both at line 187, checked via the GitHub API). This install now carries the fix below, so attestation reports LIFEOS/TOOLS/MergeSettings.ts as modified.
What is broken
When settings.system.json has no hooks key (as shipped) and the overlay LIFEOS/USER/CONFIG/settings.user.json writes a hook event as an append annotation ({ "__merge": "append", "values": [...] }, the form SettingsBackport.ts produces), MergeSettings.ts copies the annotation object into settings.json unchanged instead of resolving it to an array. Claude Code then rejects each such event at startup (Hook event "Stop" must be an array of matchers; received object. This entry was ignored.) and every hook under it stops running. On this install that was PostToolUse, SessionStart, Stop and UserPromptSubmit (38 matcher entries). MergeSettings.ts --check reports "no differences" in that state, because it compares the file against the same merge.
Where (file:line)
LifeOS/install/LIFEOS/TOOLS/MergeSettings.ts:187, in mergeSettings(): the object branch requires isObjectRecord(system) && isObjectRecord(user), so an overlay-only object key falls through to cloneJsonValue(user) and nested annotations are never resolved.
Repro on a clean tree
- Leave
settings.system.jsonwithout ahookskey (the shipped default). - In
LIFEOS/USER/CONFIG/settings.user.json, set"hooks": { "Stop": { "__merge": "append", "values": [ { "hooks": [ { "type": "command", "command": "true" } ] } ] } }. - Run
bun LIFEOS/TOOLS/MergeSettings.ts --system settings.system.json --user LIFEOS/USER/CONFIG/settings.user.json --output settings.json. hooks.Stopinsettings.jsonis the raw annotation object, and the next Claude Code launch reports it as ignored.
Minimal probe, run next to a copy of LIFEOS/TOOLS/ (plus LIFEOS/PULSE/lib/atomic-write.ts):
import { mergeSettings } from "./LIFEOS/TOOLS/MergeSettings.ts";
const merged = mergeSettings({}, {
hooks: { Stop: { __merge: "append", values: [{ hooks: [{ type: "command", command: "true" }] }] } },
});
const ok = Array.isArray(merged.hooks.Stop);
console.log(`hooks.Stop -> ${ok ? "array" : JSON.stringify(merged.hooks.Stop)}`);
process.exit(ok ? 0 : 1);
Negative control
Unpatched v8.761.0 file, bun probe.ts, exit 1:
hooks.Stop -> {"__merge":"append","values":[{"hooks":[{"type":"command","command":"true"}]}]}
Suggested fix
Recurse whenever the user value is an object, treating an absent system side as {}. Overlay-only keys then get the same annotation handling as shared keys, so a nested append annotation resolves through applyArrayMerge(undefined, annotation) to its values array. The patch applies cleanly to main.
diff --git a/LifeOS/install/LIFEOS/TOOLS/MergeSettings.ts b/LifeOS/install/LIFEOS/TOOLS/MergeSettings.ts
--- a/LifeOS/install/LIFEOS/TOOLS/MergeSettings.ts
+++ b/LifeOS/install/LIFEOS/TOOLS/MergeSettings.ts
@@ -184,7 +184,11 @@ export function mergeSettings(system: any, user: any): any {
);
}
- if (isObjectRecord(system) && isObjectRecord(user)) {
+ if (isObjectRecord(user)) {
+ // A user object whose system side is absent still recurses, so annotations nested under a key
+ // only the overlay defines resolve. settings.system.json omits `hooks`, and SettingsBackport
+ // writes hooks.<Event> as append annotations: cloning here leaked them raw into settings.json.
+ if (!isObjectRecord(system)) system = {};
const merged: Record<string, any> = {};
for (const key of Object.keys(system)) {
Verified after fix
Same probe, exit 0: hooks.Stop -> array. A real regeneration produces arrays for all four events.
Related: Report.ts cannot file this
This was written by hand because Tools/Report.ts could not produce it. Redact.ts swaps every configured name case-insensitively, and when the DA is named LifeOS every LifeOS/LIFEOS path, the repo name and the diff become <name>, and the send gate then refuses any body that still contains the name. Excluding the product name from the redaction list would fix it.
Environment
- OS: macOS 27.3 (arm64)
- Harness: claude-code
- bun: 1.4.4
- Ngôn ngữ chính
- TypeScript
- Star
- 19.9k
- Fork
- 2.5k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của danielmiessler/LifeOS
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
danielmiessler/LifeOS#2894 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
danielmiessler/LifeOS#2888 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
danielmiessler/LifeOS#2886 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
danielmiessler/LifeOS#2848 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
danielmiessler/LifeOS#2635 ·
Maintainer thường phản hồi trong vòng 5 ngày
Tất cả issue của danielmiessler/LifeOS
Issue tương tự
-
ready-for-agent
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
LucasSantana-Dev/Lucky#3257 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
XiaomiMiMo/MiMo-Code#2849 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement frontend good first issue help wanted testing-infrastructure
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 2 ngày
-
enhancement follow-up
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
obsidian-tasks-group/obsidian-tasks#4155 ·
Maintainer thường phản hồi trong vòng 1 ngày