Skip to content

fix: return error on malformed hooks JSON instead of silent data loss#169

Merged
claude[bot] merged 1 commit intomainfrom
claude/issue-166-20260227-2314
Feb 27, 2026
Merged

fix: return error on malformed hooks JSON instead of silent data loss#169
claude[bot] merged 1 commit intomainfrom
claude/issue-166-20260227-2314

Conversation

@claude
Copy link
Contributor

@claude claude bot commented Feb 27, 2026

Summary

When the hooks section of settings.json contains invalid JSON, Install now returns an error instead of silently resetting existingHooks to an empty map. This prevents Uncompact from overwriting the user's existing hooks with no warning.

Change

In internal/hooks/hooks.go (lines 136-138), replaced the silent reset with a proper error return.

Before: silently reset existingHooks to an empty map on parse error
After: return nil, fmt.Errorf("existing hooks section is not valid JSON: %w", err)

Closes #166

Generated with Claude Code

When the hooks section of settings.json contains invalid JSON, return an
error rather than silently resetting existingHooks to an empty map. This
prevents Uncompact from overwriting the user's existing hooks with no
warning.

Co-Authored-By: Grey Newell <greyshipscode@gmail.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: claude[bot] <claude[bot]@users.noreply.github.com>
@claude claude bot merged commit fbe48ae into main Feb 27, 2026
1 check passed
@claude claude bot deleted the claude/issue-166-20260227-2314 branch February 27, 2026 23:25
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.

Bug: malformed hooks JSON in settings.json silently drops existing user hooks

0 participants