{"record":{"id":"eff63d04566c2013","repo":"chenhg5/cc-connect","slug":"bridge-marshal-reconstruct-reply-ctx-w","errorCode":null,"errorMessage":"bridge: marshal reconstruct reply ctx: %w","messagePattern":"bridge: marshal reconstruct reply ctx: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/bridge.go","lineNumber":456,"sourceCode":"\t}\n\treturn value, true\n}\n\nfunc buildBridgeReconstructReplyCtx(project, sessionKey string) (string, error) {\n\tchatID, err := bridgeTransportChatID(sessionKey)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tpayload := bridgeReconstructReplyCtxPayload{\n\t\tKind:                bridgeReconstructReplyCtxKind,\n\t\tVersion:             1,\n\t\tSenderProject:       project,\n\t\tTransportChatID:     chatID,\n\t\tTransportSessionKey: sessionKey,\n\t}\n\tdata, err := json.Marshal(payload)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"bridge: marshal reconstruct reply ctx: %w\", err)\n\t}\n\treturn string(data), nil\n}\n\nfunc bridgeTransportChatID(sessionKey string) (string, error) {\n\tparts := strings.SplitN(sessionKey, \":\", 3)\n\tif len(parts) < 2 || parts[1] == \"\" {\n\t\treturn \"\", fmt.Errorf(\"bridge: invalid session key %q\", sessionKey)\n\t}\n\treturn parts[1], nil\n}\n\nfunc (bp *BridgePlatform) SendCard(ctx context.Context, replyCtx any, card *Card) error {\n\trc, ok := replyCtx.(*bridgeReplyCtx)\n\tif !ok {\n\t\treturn fmt.Errorf(\"bridge: invalid reply context\")\n\t}\n\ta := bp.server.getAdapter(rc.Platform)","sourceCodeStart":438,"sourceCodeEnd":474,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/bridge.go#L438-L474","documentation":"buildBridgeReconstructReplyCtx assembles a payload struct (sender project, transport chat ID, transport session key) and serializes it with json.Marshal. If marshalling fails — which for a struct of string fields should practically never happen — the error is wrapped with this message and returned from ReconstructReplyCtx.","triggerScenarios":"json.Marshal returns an error while serializing the reconstruct payload; only realistic if a field carries an unsupported type (e.g. a channel/func value introduced by a custom build) or JSON marshalling is globally broken.","commonSituations":"Custom forks that added non-serializable fields to the payload struct; corrupted builds; extremely rare in stock usage.","solutions":["Inspect the wrapped %w error to identify the unsupported type reported by encoding/json.","Ensure all fields of the reconstruct payload struct are JSON-serializable (strings, ints, etc.).","Rebuild from a clean checkout of the pinned version to rule out local modifications."],"exampleFix":"// before\ntype payload struct{ Extra chan struct{} `json:\"extra\"` } // not marshalable\n\n// after\ntype payload struct{ Extra string `json:\"extra\"` }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"rc, err := bp.ReconstructReplyCtx(key)\nif err != nil {\n    var me *json.MarshalTypeError\n    if errors.As(err, &me) { slog.Error(\"non-serializable payload field\", \"field\", me.Field) }\n    return err\n}","preventionTips":["Keep reconstruct payload structs limited to JSON-serializable field types.","Add a unit test that marshals the payload struct.","Avoid local forks adding exotic fields to bridge payloads."],"tags":["go","json","marshal"],"backgroundTag":"json-marshal-failed","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"}