{"record":{"id":"5900eeda024b8f74","repo":"chenhg5/cc-connect","slug":"hook-input-exceeds-d-bytes","errorCode":null,"errorMessage":"hook input exceeds %d bytes","messagePattern":"hook input exceeds (.+?) bytes","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/antigravityhook/protocol.go","lineNumber":42,"sourceCode":"}\n\ntype BridgeResponse struct {\n\tDecision string `json:\"decision\"`\n\tReason   string `json:\"reason,omitempty\"`\n}\n\n// Relay forwards one Agy hook invocation to the owning cc-connect session.\nfunc Relay(in io.Reader, out io.Writer, address, token string) error {\n\tif strings.TrimSpace(address) == \"\" || strings.TrimSpace(token) == \"\" {\n\t\treturn fmt.Errorf(\"permission bridge environment is missing\")\n\t}\n\n\tinput, err := io.ReadAll(io.LimitReader(in, maxHookInput+1))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"read hook input: %w\", err)\n\t}\n\tif len(input) > maxHookInput {\n\t\treturn fmt.Errorf(\"hook input exceeds %d bytes\", maxHookInput)\n\t}\n\tif !json.Valid(input) {\n\t\treturn fmt.Errorf(\"hook input is not valid JSON\")\n\t}\n\n\tconn, err := net.DialTimeout(\"tcp\", address, bridgeDialTimeout)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"connect permission bridge: %w\", err)\n\t}\n\tdefer func() { _ = conn.Close() }()\n\t// The listener is started before agy runs this hook, so dial failures should\n\t// fail closed quickly. After connect, wait much longer for a human response.\n\t_ = conn.SetDeadline(time.Now().Add(bridgeResponseTimeout))\n\n\tif err := json.NewEncoder(conn).Encode(BridgeRequest{Token: token, HookInput: input}); err != nil {\n\t\treturn fmt.Errorf(\"send permission request: %w\", err)\n\t}\n","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/antigravityhook/protocol.go#L24-L60","documentation":"Relay enforces a 4 MiB cap (maxHookInput) on the hook's stdin payload and returns 'hook input exceeds %d bytes' when the JSON invocation exceeds it. Oversized payloads are rejected before any network call so the bridge is never flooded.","triggerScenarios":"Agy invokes the permission hook with a hook input document larger than 4194304 bytes — e.g. a prompt/context blob embedded in the hook input that grew huge.","commonSituations":"Extremely large prompts or attached context in the permission request; a modified/buggy agy version emitting extra fields; users piping artificially large files into the hook when testing.","solutions":["Reduce the size of the prompt/context attached to the agy turn that triggers the hook","Upgrade or fix agy if it is inflating hook input beyond the spec","If legitimately needed, raise maxHookInput in agent/antigravityhook/protocol.go and rebuild","Check for runaway loops appending to the hook input upstream"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"data, _ := io.ReadAll(in)\nif len(data) > 4<<20 {\n    return fmt.Errorf(\"hook input is %d bytes; max is %d\", len(data), 4<<20)\n}","typeGuard":null,"tryCatchPattern":"if err := Relay(...); err != nil && strings.Contains(err.Error(), \"exceeds\") {\n    fmt.Fprintln(os.Stderr, \"payload too large: shrink prompt/context\")\n    os.Exit(2)\n}","preventionTips":["Keep prompts and attached context reasonably sized","Don't attach huge files to turns that will trigger permission hooks","Raise maxHookInput consciously if your workflows need bigger payloads"],"tags":["limit","payload","hook"],"backgroundTag":"payload-too-large","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}