{"record":{"id":"66bf163738540ae5","repo":"chenhg5/cc-connect","slug":"permission-bridge-environment-is-missing","errorCode":null,"errorMessage":"permission bridge environment is missing","messagePattern":"permission bridge environment is missing","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/antigravityhook/protocol.go","lineNumber":34,"sourceCode":"\tmaxHookInput          = 4 << 20\n\tbridgeDialTimeout     = 5 * time.Second\n\tbridgeResponseTimeout = 24 * time.Hour\n)\n\ntype BridgeRequest struct {\n\tToken     string          `json:\"token\"`\n\tHookInput json.RawMessage `json:\"hook_input\"`\n}\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() }()","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/antigravityhook/protocol.go#L16-L52","documentation":"Relay in the antigravity permission hook refuses to run when either the bridge address or token environment variable (CC_CONNECT_AGY_PERMISSION_ADDR / CC_CONNECT_AGY_PERMISSION_TOKEN) is empty or whitespace. The hook cannot forward the permission decision without knowing where the owning cc-connect session listens and how to authenticate.","triggerScenarios":"runAntigravityPermissionHook invokes Relay but the parent process did not export both env vars, or exported them blank; hook configured outside the cc-connect-spawned agy environment.","commonSituations":"Running agy manually from a shell without cc-connect's env; hook script copied elsewhere and executed without env inheritance; cc-connect failed to inject env when spawning agy.","solutions":["Ensure CC_CONNECT_AGY_PERMISSION_ADDR and CC_CONNECT_AGY_PERMISSION_TOKEN are exported in the environment that launches agy","Run agy through cc-connect so the hook inherits the bridge env automatically","Check hook config (wrapper script) uses `env` passthrough and doesn't scrub env vars","Add a debug print of the two vars inside the hook to confirm they are set at invocation time"],"exampleFix":"// before\nRelay(os.Stdin, os.Stdout, os.Getenv(\"ADDR\"), os.Getenv(\"TOKEN\"))\n// after\naddr, tok := os.Getenv(antigravityhook.EnvAddress), os.Getenv(antigravityhook.EnvToken)\nif addr == \"\" || tok == \"\" { /* fail with clear message */ }\nRelay(os.Stdin, os.Stdout, addr, tok)","handlingStrategy":"validation","validationCode":"addr, tok := os.Getenv(antigravityhook.EnvAddress), os.Getenv(antigravityhook.EnvToken)\nif strings.TrimSpace(addr) == \"\" || strings.TrimSpace(tok) == \"\" {\n    return fmt.Errorf(\"set %s and %s before invoking the hook\", antigravityhook.EnvAddress, antigravityhook.EnvToken)\n}","typeGuard":null,"tryCatchPattern":"if err := antigravityhook.Relay(os.Stdin, os.Stdout, addr, token); err != nil && strings.Contains(err.Error(), \"environment is missing\") {\n    fmt.Fprintln(os.Stderr, \"hook must run inside cc-connect-launched agy\")\n    os.Exit(2)\n}","preventionTips":["Always launch agy via cc-connect so bridge env is injected","Don't strip environment in hook wrapper scripts (no `env -i`)","Smoke-test the hook env with `env | grep CC_CONNECT_AGY` inside the hook during setup"],"tags":["env","permissions","hook","config"],"backgroundTag":"missing-env-var","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}