{"record":{"id":"3bf68aa429d86eb0","repo":"chenhg5/cc-connect","slug":"line-push-message-w","errorCode":null,"errorMessage":"line: push message: %w","messagePattern":"line: push message: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/line/line.go","lineNumber":280,"sourceCode":"\t}\n\n\tcontent = core.StripMarkdown(content)\n\n\t// LINE text message limit is 5000 characters\n\tmessages := splitMessage(content, 5000)\n\tfor _, text := range messages {\n\t\t_, err := p.bot.PushMessage(\n\t\t\t&messaging_api.PushMessageRequest{\n\t\t\t\tTo: rc.targetID,\n\t\t\t\tMessages: []messaging_api.MessageInterface{\n\t\t\t\t\tmessaging_api.TextMessage{\n\t\t\t\t\t\tText: text,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}, \"\",\n\t\t)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"line: push message: %w\", err)\n\t\t}\n\t}\n\treturn nil\n}\n\n// Send sends a new message (same as Reply for LINE)\nfunc (p *Platform) Send(ctx context.Context, rctx any, content string) error {\n\treturn p.Reply(ctx, rctx, content)\n}\n\nfunc splitMessage(s string, maxLen int) []string {\n\tif len(s) <= maxLen {\n\t\treturn []string{s}\n\t}\n\tvar parts []string\n\trunes := []rune(s)\n\tfor len(runes) > 0 {\n\t\tend := maxLen","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/line/line.go#L262-L298","documentation":"In Reply, platform/line/line.go:280, the LINE client's PushMessage API call failed and the error is wrapped as \"line: push message: %w\". The library throws it whenever sending a proactive/push message to the LINE Messaging API returns a non-nil error (network failure, invalid token, or invalid targetID). It propagates the underlying LINE API error so callers can see the root cause.","triggerScenarios":"Calling Reply when the underlying linebot client PushMessage call (to the target user/group/channel text) returns an error — e.g. HTTP error from LINE servers, network outage, expired/invalid channel access token, or the bot has no relationship with the target ID.","commonSituations":"Bot tries to push a message to a user who has not added it as a friend (LINE requires no push to non-friends); channel token revoked or expired; LINE platform outage or rate limit; misconfigured target ID in session key.","solutions":["Check the wrapped inner error (via errors.Unwrap or %v of the error) for the LINE API status code and message","Verify the channel access token is valid and not expired; refresh/rotate it","Confirm the bot is a friend of / member of the target user or group before pushing","Retry on transient network/5xx errors with backoff; respect LINE rate limits"],"exampleFix":"// before\nif err != nil {\n    return fmt.Errorf(\"line: push message: %w\", err)\n}\n// after\nif err != nil {\n    var apiErr *linebot.APIError\n    if errors.As(err, &apiErr) && apiErr.Code == 429 {\n        return retryAfterBackoff(...)\n    }\n    return fmt.Errorf(\"line: push message: %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"if !strings.HasPrefix(sessionKey, \"line:\") { return fmt.Errorf(\"not a LINE session key\") }","typeGuard":"func isLinebotAPIError(err error) (*linebot.APIError, bool) { var e *linebot.APIError; ok := errors.As(err, &e); return e, ok }","tryCatchPattern":"if err != nil {\n    var apiErr *linebot.APIError\n    if errors.As(err, &apiErr) {\n        slog.Warn(\"line push failed\", \"code\", apiErr.Code, \"msg\", apiErr.Message)\n        if apiErr.Code == 429 { /* backoff + retry */ }\n        return\n    }\n    slog.Error(\"line push failed\", \"err\", err)\n}","preventionTips":["Keep the channel access token refreshed before expiry","Only push to users/groups where the bot has an established relationship","Implement exponential backoff for 429/5xx responses","Log the unwrapped inner error to see the LINE API status code"],"tags":["line","push-message","api-error","network"],"backgroundTag":"api-request-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"}