{"record":{"id":"6245c840d1e64356","repo":"chenhg5/cc-connect","slug":"webex-invalid-reply-context-t","errorCode":null,"errorMessage":"webex: invalid reply context %T","messagePattern":"webex: invalid reply context %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/webex/webex_reply.go","lineNumber":19,"sourceCode":"package webex\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"strings\"\n\t\"unicode/utf8\"\n\n\t\"github.com/chenhg5/cc-connect/core\"\n)\n\n// webexMaxBytes is Webex's per-message body cap.\nconst webexMaxBytes = 7439\n\n// asReplyContext recovers a replyContext from the engine's any-typed value.\nfunc asReplyContext(replyCtx any) (replyContext, error) {\n\trc, ok := replyCtx.(replyContext)\n\tif !ok {\n\t\treturn replyContext{}, fmt.Errorf(\"webex: invalid reply context %T\", replyCtx)\n\t}\n\treturn rc, nil\n}\n\n// Reply posts a threaded response to the originating message.\nfunc (p *Platform) Reply(ctx context.Context, replyCtx any, content string) error {\n\trc, err := asReplyContext(replyCtx)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn p.post(ctx, rc.roomID, rc.messageID, content)\n}\n\n// Send posts a non-threaded (proactive) message to the room.\nfunc (p *Platform) Send(ctx context.Context, replyCtx any, content string) error {\n\trc, err := asReplyContext(replyCtx)\n\tif err != nil {\n\t\treturn err","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/webex/webex_reply.go#L1-L37","documentation":"asReplyContext recovers the platform-specific replyContext from the engine's any-typed reply context value. If the value was not produced by this Webex platform (wrong concrete type), it returns this error naming the actual Go type received. It is an internal invariant violation across the platform boundary.","triggerScenarios":"Calling Reply/Send/SendImage/SendFile with a replyCtx value captured from a different platform's message, a nil value, or an altered/reconstructed value that is not of type replyContext.","commonSituations":"Routing engine bug forwarding another platform's reply context to the Webex platform; storing a reply context, restarting with a different platform type, then replying; tests passing a raw string/struct instead of the value obtained from ReceiveMessage.","solutions":["Always pass the replyCtx value received from the engine's message event back verbatim — never reconstruct it","Ensure messages from other platforms are not routed to the Webex platform's Reply/Send","Check engine routing logic for mixing reply contexts across platforms","In tests, use the actual replyContext returned by the Webex platform rather than a hand-made value"],"exampleFix":"// before\np.Reply(ctx, someOtherPlatformCtx, \"hi\")\n// after\nif msg.Platform == \"webex\" {\n    p.Reply(ctx, msg.ReplyContext, \"hi\")\n}","handlingStrategy":"type-guard","validationCode":"if _, ok := replyCtx.(webex.ReplyContext); !ok {\n    return errors.New(\"reply context does not belong to webex platform\")\n}","typeGuard":"func isValidWebexReplyContext(v any) bool {\n    _, ok := v.(webex.ReplyContext)\n    return ok\n}","tryCatchPattern":"if err := p.Reply(ctx, replyCtx, text); err != nil {\n    if strings.Contains(err.Error(), \"invalid reply context\") {\n        return fmt.Errorf(\"reply ctx not from webex; check routing: %w\", err)\n    }\n    return err\n}","preventionTips":["Always return the replyCtx from the message event untouched — never rebuild or copy fields","Never route one platform's reply context to a different platform's Reply/Send","Use type-guard checks at routing boundaries before dispatching to platform adapters","Add engine tests covering cross-platform routing to catch context mixing early"],"tags":["webex","type-mismatch","internal","reply-context"],"backgroundTag":"type-mismatch","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"}