{"record":{"id":"8380652414f2889b","repo":"chenhg5/cc-connect","slug":"max-start-webhook-w","errorCode":null,"errorMessage":"max: start webhook: %w","messagePattern":"max: start webhook: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/max/max.go","lineNumber":177,"sourceCode":"\t\treturn fmt.Errorf(\"max: platform stopped\")\n\t}\n\tp.handler = handler\n\n\tctx, cancel := context.WithCancel(context.Background())\n\tp.ctx = ctx\n\tp.cancel = cancel\n\n\t// Verify token at startup\n\tif name, id, err := p.getMe(ctx); err != nil {\n\t\tslog.Warn(\"max: could not verify bot token\", \"error\", err)\n\t} else {\n\t\tslog.Info(\"max: connected\", \"bot\", name, \"id\", id)\n\t}\n\n\tif p.webhookURL != \"\" {\n\t\tif err := p.startWebhook(ctx); err != nil {\n\t\t\tcancel()\n\t\t\treturn fmt.Errorf(\"max: start webhook: %w\", err)\n\t\t}\n\t\treturn nil\n\t}\n\n\tgo p.pollLoop(ctx)\n\treturn nil\n}\n\nfunc (p *Platform) Stop() error {\n\tp.mu.Lock()\n\tsrv := p.webServer\n\turl := p.webhookURL\n\tp.stopping = true\n\tif p.cancel != nil {\n\t\tp.cancel()\n\t}\n\tp.mu.Unlock()\n\tif srv != nil {","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/max/max.go#L159-L195","documentation":"Wraps any error returned by startWebhook when the platform is configured with a webhook URL. Start cancels the background context and aborts startup, propagating the cause (subscription or listener failure) with this prefix.","triggerScenarios":"Configuring opts[\"webhook_url\"] and calling Start when the local HTTP listener cannot bind, or the MAX webhook subscribe call fails (network error, bad URL, HTTP >= 300 from the API).","commonSituations":"Port already in use for the webhook server, unreachable/invalid public webhook URL passed to MAX, expired or missing bot token causing subscribe to be rejected.","solutions":["Inspect the wrapped inner error: if it's a bind failure, free the port or change webhook_listen address.","If the inner error is \"subscribe: ...\" / \"HTTP xxx\", verify the webhook URL is publicly reachable and the token is valid.","Temporarily run in polling mode by removing the webhook_url option to isolate webhook-specific issues."],"exampleFix":"// before\nopts[\"webhook_url\"] = \"http://localhost:8080/hook\" // not publicly reachable\n// after\nopts[\"webhook_url\"] = \"https://example.com/max/hook\"","handlingStrategy":"try-catch","validationCode":"if url, ok := opts[\"webhook_url\"].(string); ok && url != \"\" {\n    u, err := neturl.Parse(url)\n    if err != nil || u.Scheme != \"https\" { return errors.New(\"webhook_url must be a valid https URL\") }\n}","typeGuard":null,"tryCatchPattern":"if err := p.Start(handler); err != nil {\n    var inner error\n    if errors.As(err, &inner) { slog.Error(\"max start failed\", \"err\", err) }\n    return fmt.Errorf(\"platform start failed: %w\", err)\n}","preventionTips":["Verify the webhook URL is publicly reachable (HTTPS, valid cert) before startup","Check port availability for the local webhook listener","Validate the bot token before calling Start","Fall back to polling mode if webhook setup repeatedly fails"],"tags":["go","webhook","startup"],"backgroundTag":"http-error-response","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"}