chenhg5/cc-connect · error
marshal Agy hooks overlay: %w
Error message
marshal Agy hooks overlay: %w
What it means
After merging existing hooks with the bridge hook, createAgyConfigOverlay serializes the full hooks map with json.MarshalIndent to write the overlay hooks.json. If marshaling fails, this wrapped error is returned.
Source
Thrown at agent/antigravity/permission_bridge.go:157
"matcher": "*",
"hooks": []any{
map[string]any{
"type": "command",
"command": shellQuote(executable) + " _agy-permission-hook",
"timeout": 86400,
},
},
},
},
})
if err != nil {
return "", fmt.Errorf("marshal Agy permission hook: %w", err)
}
hooks[agyPermissionHookName] = bridgeHook
data, err := json.MarshalIndent(hooks, "", " ")
if err != nil {
return "", fmt.Errorf("marshal Agy hooks overlay: %w", err)
}
data = append(data, '\n')
if err := os.WriteFile(filepath.Join(overlayConfigDir, "hooks.json"), data, 0o600); err != nil {
return "", fmt.Errorf("write Agy hooks overlay: %w", err)
}
return overlayConfigRoot, nil
}
func mirrorDirectoryEntries(sourceDir, targetDir string, skip map[string]bool) error {
entries, err := os.ReadDir(sourceDir)
if os.IsNotExist(err) {
return nil
}
if err != nil {
return fmt.Errorf("read Agy config directory %s: %w", sourceDir, err)
}
for _, entry := range entries {
if skip[entry.Name()] {View on GitHub (pinned to 4000b2338a)
Solutions
- Validate and fix the original ~/.gemini/config/hooks.json so every entry is well-formed JSON.
- Temporarily rename the real hooks.json and retry session start to confirm the existing content is the culprit.
- Remove the offending hook entry and re-add it in valid JSON form.
- Rebuild cc-connect if running a modified build with altered hook structures.
Example fix
// before: hooks.json entry that can't re-marshal
{"myHook": "{unclosed"}
// after
{"myHook": {"command": "/usr/bin/hook"}} Defensive patterns
Strategy: validation
Validate before calling
// shell: ensure every existing hook entry is valid JSON before starting
python3 - <<'EOF'
import json,os
p=os.path.expanduser('~/.gemini/config/hooks.json')
h=json.load(open(p))
assert isinstance(h, dict)
for k,v in h.items(): json.dumps(json.loads(json.dumps(v)))
EOF Try / catch
if err := startAntigravitySession(); err != nil && strings.Contains(err.Error(), "marshal Agy hooks overlay") {
// identify the offending hook entry, fix or drop it, retry
} Prevention
- Keep hook entries as plain JSON objects with primitive values.
- Validate hooks.json after any external tool writes to it.
- Re-generate hooks from known-good templates instead of hand-edits.
When it happens
Trigger: newAgyPermissionBridge → createAgyConfigOverlay when json.MarshalIndent(hooks) fails — typically because an existing hook entry loaded from ~/.gemini/config/hooks.json (stored as json.RawMessage) is invalid or contains values that cannot be re-marshaled.
Common situations: A hand-crafted hooks.json containing entries with unsupported values (e.g. NaN-like tokens from other tooling, or corrupted RawMessage content) that fail re-serialization.
Understand the failure class
Background: "JSON serialization failed", "not JSON serializable", "Failed to serialize": why JSON marshaling errors happen and how to fix them — this error's family across 46 libraries.
Related errors
- parse existing Agy hooks %s: %w
- marshal Agy permission hook: %w
- bridge: marshal reconstruct reply ctx: %w
- minimax tts: marshal request: %w
- listen for Agy permission hooks: %w
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/966aeb78e1e4ccf4.
Report an issue: GitHub.