From 2fe6ac93de10199de8409fa55569b1714fad2e75 Mon Sep 17 00:00:00 2001 From: Norbert Kwizera Date: Tue, 21 May 2024 17:46:44 +0200 Subject: [PATCH 1/3] Use std library errors, part 2 --- backends/rapidpro/backend.go | 39 +++++++++++++++-------------- backends/rapidpro/contact.go | 16 ++++++------ backends/rapidpro/msg.go | 9 +++---- backends/rapidpro/status.go | 7 +++--- backends/rapidpro/urn.go | 13 +++++----- go.mod | 2 +- handlers/facebook_legacy/handler.go | 15 +++++------ handlers/jiochat/handler.go | 3 ++- handlers/kaleyra/handler.go | 3 ++- handlers/line/handler.go | 3 ++- handlers/media.go | 4 +-- handlers/meta/handlers.go | 15 +++++------ handlers/shaqodoon/handler.go | 3 ++- handlers/slack/handler.go | 9 ++++--- handlers/telegram/handler.go | 7 +++--- handlers/viber/handler.go | 3 ++- handlers/vk/handler.go | 3 ++- handlers/wechat/handler.go | 3 ++- handlers/whatsapp_legacy/handler.go | 5 ++-- handlers/yo/handler.go | 3 ++- sender.go | 3 ++- server.go | 3 ++- test/backend.go | 3 ++- test/handler.go | 3 ++- 24 files changed, 98 insertions(+), 79 deletions(-) diff --git a/backends/rapidpro/backend.go b/backends/rapidpro/backend.go index a05ffe009..260a9975a 100644 --- a/backends/rapidpro/backend.go +++ b/backends/rapidpro/backend.go @@ -18,6 +18,8 @@ import ( "sync" "time" + "errors" + "github.com/aws/aws-sdk-go/service/s3" "github.com/gomodule/redigo/redis" "github.com/jmoiron/sqlx" @@ -33,7 +35,6 @@ import ( "github.com/nyaruka/gocommon/urns" "github.com/nyaruka/gocommon/uuids" "github.com/nyaruka/redisx" - "github.com/pkg/errors" ) // the name for our message queue @@ -359,7 +360,7 @@ func (b *backend) DeleteMsgByExternalID(ctx context.Context, channel courier.Cha var msgID courier.MsgID var contactID ContactID if err := row.Scan(&msgID, &contactID); err != nil && err != sql.ErrNoRows { - return errors.Wrap(err, "error querying deleted msg") + return fmt.Errorf("error querying deleted msg: %w", err) } if msgID != courier.NilMsgID && contactID != NilContactID { @@ -367,7 +368,7 @@ func (b *backend) DeleteMsgByExternalID(ctx context.Context, channel courier.Cha defer rc.Close() if err := queueMsgDeleted(rc, ch, msgID, contactID); err != nil { - return errors.Wrap(err, "error queuing message deleted task") + return fmt.Errorf("error queuing message deleted task: %w", err) } } @@ -416,7 +417,7 @@ func (b *backend) PopNextOutgoingMsg(ctx context.Context) (courier.MsgOut, error err = json.Unmarshal([]byte(msgJSON), dbMsg) if err != nil { queue.MarkComplete(rc, msgQueueName, token) - return nil, errors.Wrapf(err, "unable to unmarshal message: %s", string(msgJSON)) + return nil, fmt.Errorf("unable to unmarshal message: %s: %w", string(msgJSON), err) } // populate the channel on our db msg @@ -536,7 +537,7 @@ func (b *backend) WriteStatusUpdate(ctx context.Context, status courier.StatusUp if oldURN != urns.NilURN && newURN != urns.NilURN { err := b.updateContactURN(ctx, status) if err != nil { - return errors.Wrap(err, "error updating contact URN") + return fmt.Errorf("error updating contact URN: %w", err) } } @@ -575,7 +576,7 @@ func (b *backend) updateContactURN(ctx context.Context, status courier.StatusUpd // retrieve channel channel, err := b.GetChannel(ctx, courier.AnyChannelType, status.ChannelUUID()) if err != nil { - return errors.Wrap(err, "error retrieving channel") + return fmt.Errorf("error retrieving channel: %w", err) } dbChannel := channel.(*Channel) tx, err := b.db.BeginTxx(ctx, nil) @@ -585,7 +586,7 @@ func (b *backend) updateContactURN(ctx context.Context, status courier.StatusUpd // retrieve the old URN oldContactURN, err := getContactURNByIdentity(tx, dbChannel.OrgID(), old) if err != nil { - return errors.Wrap(err, "error retrieving old contact URN") + return fmt.Errorf("error retrieving old contact URN: %w", err) } // retrieve the new URN newContactURN, err := getContactURNByIdentity(tx, dbChannel.OrgID(), new) @@ -598,11 +599,11 @@ func (b *backend) updateContactURN(ctx context.Context, status courier.StatusUpd err = fullyUpdateContactURN(tx, oldContactURN) if err != nil { tx.Rollback() - return errors.Wrap(err, "error updating old contact URN") + return fmt.Errorf("error updating old contact URN: %w", err) } return tx.Commit() } - return errors.Wrap(err, "error retrieving new contact URN") + return fmt.Errorf("error retrieving new contact URN: %w", err) } // only update the new URN if it doesn't have an associated contact @@ -616,12 +617,12 @@ func (b *backend) updateContactURN(ctx context.Context, status courier.StatusUpd err = fullyUpdateContactURN(tx, newContactURN) if err != nil { tx.Rollback() - return errors.Wrap(err, "error updating new contact URN") + return fmt.Errorf("error updating new contact URN: %w", err) } err = fullyUpdateContactURN(tx, oldContactURN) if err != nil { tx.Rollback() - return errors.Wrap(err, "error updating old contact URN") + return fmt.Errorf("error updating old contact URN: %w", err) } return tx.Commit() } @@ -663,7 +664,7 @@ func (b *backend) SaveAttachment(ctx context.Context, ch courier.Channel, conten storageURL, err := b.attachmentStorage.Put(ctx, path, contentType, data) if err != nil { - return "", errors.Wrapf(err, "error saving attachment to storage (bytes=%d)", len(data)) + return "", fmt.Errorf("error saving attachment to storage (bytes=%d): %w", len(data), err) } return storageURL, nil @@ -673,7 +674,7 @@ func (b *backend) SaveAttachment(ctx context.Context, ch courier.Channel, conten func (b *backend) ResolveMedia(ctx context.Context, mediaUrl string) (courier.Media, error) { u, err := url.Parse(mediaUrl) if err != nil { - return nil, errors.Wrapf(err, "error parsing media URL") + return nil, fmt.Errorf("error parsing media URL: %w", err) } mediaUUID := uuidRegex.FindString(u.Path) @@ -692,7 +693,7 @@ func (b *backend) ResolveMedia(ctx context.Context, mediaUrl string) (courier.Me var media *Media mediaJSON, err := b.mediaCache.Get(rc, mediaUUID) if err != nil { - return nil, errors.Wrap(err, "error looking up cached media") + return nil, fmt.Errorf("error looking up cached media: %w", err) } if mediaJSON != "" { jsonx.MustUnmarshal([]byte(mediaJSON), &media) @@ -700,7 +701,7 @@ func (b *backend) ResolveMedia(ctx context.Context, mediaUrl string) (courier.Me // lookup media in our database media, err = lookupMediaFromUUID(ctx, b.db, uuids.UUID(mediaUUID)) if err != nil { - return nil, errors.Wrap(err, "error looking up media") + return nil, fmt.Errorf("error looking up media: %w", err) } // cache it for future requests @@ -756,11 +757,11 @@ func (b *backend) Heartbeat() error { active, err := redis.Strings(rc.Do("ZRANGE", fmt.Sprintf("%s:active", msgQueueName), "0", "-1")) if err != nil { - return errors.Wrapf(err, "error getting active queues") + return fmt.Errorf("error getting active queues: %w", err) } throttled, err := redis.Strings(rc.Do("ZRANGE", fmt.Sprintf("%s:throttled", msgQueueName), "0", "-1")) if err != nil { - return errors.Wrapf(err, "error getting throttled queues") + return fmt.Errorf("error getting throttled queues: %w", err) } queues := append(active, throttled...) @@ -770,14 +771,14 @@ func (b *backend) Heartbeat() error { q := fmt.Sprintf("%s/1", queue) count, err := redis.Int(rc.Do("ZCARD", q)) if err != nil { - return errors.Wrapf(err, "error getting size of priority queue: %s", q) + return fmt.Errorf("error getting size of priority queue: %s: %w", q, err) } prioritySize += count q = fmt.Sprintf("%s/0", queue) count, err = redis.Int(rc.Do("ZCARD", q)) if err != nil { - return errors.Wrapf(err, "error getting size of bulk queue: %s", q) + return fmt.Errorf("error getting size of bulk queue: %s: %w", q, err) } bulkSize += count } diff --git a/backends/rapidpro/contact.go b/backends/rapidpro/contact.go index 923363716..94f2328cb 100644 --- a/backends/rapidpro/contact.go +++ b/backends/rapidpro/contact.go @@ -4,6 +4,7 @@ import ( "context" "database/sql" "database/sql/driver" + "fmt" "log/slog" "strconv" "time" @@ -16,7 +17,6 @@ import ( "github.com/nyaruka/gocommon/urns" "github.com/nyaruka/gocommon/uuids" "github.com/nyaruka/null/v3" - "github.com/pkg/errors" ) // used by unit tests to slow down urn operations to test races @@ -110,7 +110,7 @@ func contactForURN(ctx context.Context, b *backend, org OrgID, channel *Channel, err := b.db.GetContext(ctx, contact, lookupContactFromURNSQL, urn.Identity(), org) if err != nil && err != sql.ErrNoRows { log.Error("error looking up contact by URN", "error", err) - return nil, errors.Wrap(err, "error looking up contact by URN") + return nil, fmt.Errorf("error looking up contact by URN: %w", err) } // we found it, return it @@ -118,7 +118,7 @@ func contactForURN(ctx context.Context, b *backend, org OrgID, channel *Channel, tx, err := b.db.BeginTxx(ctx, nil) if err != nil { log.Error("error beginning transaction", "error", err) - return nil, errors.Wrap(err, "error beginning transaction") + return nil, fmt.Errorf("error beginning transaction: %w", err) } // update contact's URNs so this URN has priority @@ -126,7 +126,7 @@ func contactForURN(ctx context.Context, b *backend, org OrgID, channel *Channel, if err != nil { log.Error("error updating default URN for contact", "error", err) tx.Rollback() - return nil, errors.Wrap(err, "error setting default URN for contact") + return nil, fmt.Errorf("error setting default URN for contact: %w", err) } return contact, tx.Commit() } @@ -174,13 +174,13 @@ func contactForURN(ctx context.Context, b *backend, org OrgID, channel *Channel, // insert it tx, err := b.db.BeginTxx(ctx, nil) if err != nil { - return nil, errors.Wrap(err, "error beginning transaction") + return nil, fmt.Errorf("error beginning transaction: %w", err) } err = insertContact(tx, contact) if err != nil { tx.Rollback() - return nil, errors.Wrap(err, "error inserting contact") + return nil, fmt.Errorf("error inserting contact: %w", err) } // used for unit testing contact races @@ -199,7 +199,7 @@ func contactForURN(ctx context.Context, b *backend, org OrgID, channel *Channel, // if this was a duplicate URN, start over with a contact lookup return contactForURN(ctx, b, org, channel, urn, authTokens, name, clog) } - return nil, errors.Wrap(err, "error getting URN for contact") + return nil, fmt.Errorf("error getting URN for contact: %w", err) } // we stole the URN from another contact, roll back and start over @@ -211,7 +211,7 @@ func contactForURN(ctx context.Context, b *backend, org OrgID, channel *Channel, // all is well, we created the new contact, commit and move forward err = tx.Commit() if err != nil { - return nil, errors.Wrap(err, "error commiting transaction") + return nil, fmt.Errorf("error commiting transaction: %w", err) } // store this URN on our contact diff --git a/backends/rapidpro/msg.go b/backends/rapidpro/msg.go index bafa29bb2..3b9d2b5c8 100644 --- a/backends/rapidpro/msg.go +++ b/backends/rapidpro/msg.go @@ -23,7 +23,6 @@ import ( "github.com/nyaruka/gocommon/urns" "github.com/nyaruka/gocommon/uuids" "github.com/nyaruka/null/v3" - "github.com/pkg/errors" ) // MsgDirection is the direction of a message @@ -204,7 +203,7 @@ func writeMsg(ctx context.Context, b *backend, msg courier.MsgIn, clog *courier. attData, err := base64.StdEncoding.DecodeString(attURL[5:]) if err != nil { clog.Error(courier.ErrorAttachmentNotDecodable()) - return errors.Wrap(err, "unable to decode attachment data") + return fmt.Errorf("unable to decode attachment data: %w", err) } var contentType, extension string @@ -257,7 +256,7 @@ func writeMsgToDB(ctx context.Context, b *backend, m *Msg, clog *courier.Channel // our db is down, write to the spool, we will write/queue this later if err != nil { - return errors.Wrap(err, "error getting contact for message") + return fmt.Errorf("error getting contact for message: %w", err) } // set our contact and urn id @@ -266,14 +265,14 @@ func writeMsgToDB(ctx context.Context, b *backend, m *Msg, clog *courier.Channel rows, err := b.db.NamedQueryContext(ctx, sqlInsertMsg, m) if err != nil { - return errors.Wrap(err, "error inserting message") + return fmt.Errorf("error inserting message: %w", err) } defer rows.Close() rows.Next() err = rows.Scan(&m.ID_) if err != nil { - return errors.Wrap(err, "error scanning for inserted message id") + return fmt.Errorf("error scanning for inserted message id: %w", err) } // queue this up to be handled by RapidPro diff --git a/backends/rapidpro/status.go b/backends/rapidpro/status.go index dfda32b03..e5de77cf6 100644 --- a/backends/rapidpro/status.go +++ b/backends/rapidpro/status.go @@ -10,11 +10,12 @@ import ( "sync" "time" + "errors" + "github.com/nyaruka/courier" "github.com/nyaruka/gocommon/dbutil" "github.com/nyaruka/gocommon/syncx" "github.com/nyaruka/gocommon/urns" - "github.com/pkg/errors" ) // StatusUpdate represents a status update on a message @@ -244,7 +245,7 @@ func (b *backend) writeStatusUpdatesToDB(ctx context.Context, statuses []*Status err := dbutil.BulkQuery(ctx, b.db, sqlUpdateMsgByID, resolved) if err != nil { - return nil, errors.Wrap(err, "error updating status") + return nil, fmt.Errorf("error updating status: %w", err) } return unresolved, nil @@ -313,7 +314,7 @@ func (b *backend) resolveStatusUpdateMsgIDs(ctx context.Context, statuses []*Sta for rows.Next() { if err := rows.Scan(&msgID, &channelID, &externalID); err != nil { - return errors.Wrap(err, "error scanning rows") + return fmt.Errorf("error scanning rows: %w", err) } // find the status with this channel ID and external ID and update its msg ID diff --git a/backends/rapidpro/urn.go b/backends/rapidpro/urn.go index b57ced17c..c88916f37 100644 --- a/backends/rapidpro/urn.go +++ b/backends/rapidpro/urn.go @@ -11,7 +11,6 @@ import ( "github.com/nyaruka/courier/utils" "github.com/nyaruka/gocommon/urns" "github.com/nyaruka/null/v3" - "github.com/pkg/errors" ) // ContactURNID represents a contact urn's id @@ -178,14 +177,14 @@ func getOrCreateContactURN(db *sqlx.Tx, channel *Channel, contactID ContactID, u } err := db.Get(contactURN, sqlSelectURNByIdentity, channel.OrgID(), urn.Identity()) if err != nil && err != sql.ErrNoRows { - return nil, errors.Wrap(err, "error looking up URN by identity") + return nil, fmt.Errorf("error looking up URN by identity: %w", err) } // we didn't find it, let's insert it if err == sql.ErrNoRows { err = insertContactURN(db, contactURN) if err != nil { - return nil, errors.Wrap(err, "error inserting URN") + return nil, fmt.Errorf("error inserting URN: %w", err) } } @@ -201,7 +200,7 @@ func getOrCreateContactURN(db *sqlx.Tx, channel *Channel, contactID ContactID, u contactURN.Display = display err = updateContactURN(db, contactURN) if err != nil { - return nil, errors.Wrap(err, "error updating URN") + return nil, fmt.Errorf("error updating URN: %w", err) } } @@ -211,8 +210,10 @@ func getOrCreateContactURN(db *sqlx.Tx, channel *Channel, contactID ContactID, u err = updateContactURN(db, contactURN) } - - return contactURN, errors.Wrap(err, "error updating URN auth") + if err != nil { + return contactURN, fmt.Errorf("error updating URN auth: %w", err) + } + return contactURN, nil } const sqlInsertURN = ` diff --git a/go.mod b/go.mod index fc6d87547..0b6d29563 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,6 @@ require ( github.com/nyaruka/null/v3 v3.0.0 github.com/nyaruka/redisx v0.8.0 github.com/patrickmn/go-cache v2.1.0+incompatible - github.com/pkg/errors v0.9.1 github.com/samber/slog-multi v1.0.2 github.com/samber/slog-sentry v1.2.2 github.com/stretchr/testify v1.9.0 @@ -49,6 +48,7 @@ require ( github.com/nyaruka/librato v1.1.1 // indirect github.com/nyaruka/null/v2 v2.0.3 // indirect github.com/nyaruka/phonenumbers v1.3.5 // indirect + github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/samber/lo v1.39.0 // indirect github.com/shopspring/decimal v1.4.0 // indirect diff --git a/handlers/facebook_legacy/handler.go b/handlers/facebook_legacy/handler.go index 1a87fe502..29e49ab8b 100644 --- a/handlers/facebook_legacy/handler.go +++ b/handlers/facebook_legacy/handler.go @@ -10,13 +10,14 @@ import ( "strings" "time" + "errors" + "github.com/buger/jsonparser" "github.com/nyaruka/courier" "github.com/nyaruka/courier/handlers" "github.com/nyaruka/courier/utils" "github.com/nyaruka/gocommon/jsonx" "github.com/nyaruka/gocommon/urns" - "github.com/pkg/errors" ) // Endpoints we hit @@ -564,29 +565,29 @@ func (h *handler) Send(ctx context.Context, msg courier.MsgOut, res *courier.Sen realIDURN, err := urns.New(urns.Facebook, recipientID) if err != nil { - clog.RawError(errors.Errorf("unable to make facebook urn from %s", recipientID)) + clog.RawError(fmt.Errorf("unable to make facebook urn from %s", recipientID)) } contact, err := h.Backend().GetContact(ctx, msg.Channel(), msg.URN(), nil, "", clog) if err != nil { - clog.RawError(errors.Errorf("unable to get contact for %s", msg.URN().String())) + clog.RawError(fmt.Errorf("unable to get contact for %s", msg.URN().String())) } realURN, err := h.Backend().AddURNtoContact(ctx, msg.Channel(), contact, realIDURN, nil) if err != nil { - clog.RawError(errors.Errorf("unable to add real facebook URN %s to contact with uuid %s", realURN.String(), contact.UUID())) + clog.RawError(fmt.Errorf("unable to add real facebook URN %s to contact with uuid %s", realURN.String(), contact.UUID())) } referralIDExtURN, err := urns.New(urns.External, referralID) if err != nil { - clog.RawError(errors.Errorf("unable to make ext urn from %s", referralID)) + clog.RawError(fmt.Errorf("unable to make ext urn from %s", referralID)) } extURN, err := h.Backend().AddURNtoContact(ctx, msg.Channel(), contact, referralIDExtURN, nil) if err != nil { - clog.RawError(errors.Errorf("unable to add URN %s to contact with uuid %s", extURN.String(), contact.UUID())) + clog.RawError(fmt.Errorf("unable to add URN %s to contact with uuid %s", extURN.String(), contact.UUID())) } referralFacebookURN, err := h.Backend().RemoveURNfromContact(ctx, msg.Channel(), contact, msg.URN()) if err != nil { - clog.RawError(errors.Errorf("unable to remove referral facebook URN %s from contact with uuid %s", referralFacebookURN.String(), contact.UUID())) + clog.RawError(fmt.Errorf("unable to remove referral facebook URN %s from contact with uuid %s", referralFacebookURN.String(), contact.UUID())) } } diff --git a/handlers/jiochat/handler.go b/handlers/jiochat/handler.go index c5379ae97..49558513c 100644 --- a/handlers/jiochat/handler.go +++ b/handlers/jiochat/handler.go @@ -14,13 +14,14 @@ import ( "sync" "time" + "errors" + "github.com/buger/jsonparser" "github.com/gomodule/redigo/redis" "github.com/nyaruka/courier" "github.com/nyaruka/courier/handlers" "github.com/nyaruka/gocommon/jsonx" "github.com/nyaruka/gocommon/urns" - "github.com/pkg/errors" ) var ( diff --git a/handlers/kaleyra/handler.go b/handlers/kaleyra/handler.go index bd38bbf98..94c76ee7a 100644 --- a/handlers/kaleyra/handler.go +++ b/handlers/kaleyra/handler.go @@ -12,11 +12,12 @@ import ( "strings" "time" + "errors" + "github.com/buger/jsonparser" "github.com/nyaruka/courier" "github.com/nyaruka/courier/handlers" "github.com/nyaruka/gocommon/urns" - "github.com/pkg/errors" ) const ( diff --git a/handlers/line/handler.go b/handlers/line/handler.go index 326d1b681..a684137aa 100644 --- a/handlers/line/handler.go +++ b/handlers/line/handler.go @@ -14,10 +14,11 @@ import ( "strconv" "time" + "errors" + "github.com/nyaruka/courier" "github.com/nyaruka/courier/handlers" "github.com/nyaruka/gocommon/urns" - "github.com/pkg/errors" ) var ( diff --git a/handlers/media.go b/handlers/media.go index 136040584..14a724b1b 100644 --- a/handlers/media.go +++ b/handlers/media.go @@ -2,12 +2,12 @@ package handlers import ( "context" + "fmt" "net/url" "path" "strings" "github.com/nyaruka/courier" - "github.com/pkg/errors" ) type MediaType string @@ -42,7 +42,7 @@ func ResolveAttachments(ctx context.Context, b courier.Backend, attachments []st // split into content-type and URL parts := strings.SplitN(as, ":", 2) if len(parts) <= 1 || strings.HasPrefix(parts[1], "//") { - return nil, errors.Errorf("invalid attachment format: %s", as) + return nil, fmt.Errorf("invalid attachment format: %s", as) } contentType, mediaUrl := parts[0], parts[1] diff --git a/handlers/meta/handlers.go b/handlers/meta/handlers.go index d7a357854..bb431b5cd 100644 --- a/handlers/meta/handlers.go +++ b/handlers/meta/handlers.go @@ -14,6 +14,8 @@ import ( "strings" "time" + "errors" + "github.com/buger/jsonparser" "github.com/nyaruka/courier" "github.com/nyaruka/courier/handlers" @@ -22,7 +24,6 @@ import ( "github.com/nyaruka/courier/utils" "github.com/nyaruka/gocommon/jsonx" "github.com/nyaruka/gocommon/urns" - "github.com/pkg/errors" ) // Endpoints we hit @@ -750,29 +751,29 @@ func (h *handler) sendFacebookInstagramMsg(ctx context.Context, msg courier.MsgO realIDURN, err := urns.New(urns.Facebook, recipientID) if err != nil { - clog.RawError(errors.Errorf("unable to make facebook urn from %s", recipientID)) + clog.RawError(fmt.Errorf("unable to make facebook urn from %s", recipientID)) } contact, err := h.Backend().GetContact(ctx, msg.Channel(), msg.URN(), nil, "", clog) if err != nil { - clog.RawError(errors.Errorf("unable to get contact for %s", msg.URN().String())) + clog.RawError(fmt.Errorf("unable to get contact for %s", msg.URN().String())) } realURN, err := h.Backend().AddURNtoContact(ctx, msg.Channel(), contact, realIDURN, nil) if err != nil { - clog.RawError(errors.Errorf("unable to add real facebook URN %s to contact with uuid %s", realURN.String(), contact.UUID())) + clog.RawError(fmt.Errorf("unable to add real facebook URN %s to contact with uuid %s", realURN.String(), contact.UUID())) } referralIDExtURN, err := urns.New(urns.External, referralID) if err != nil { - clog.RawError(errors.Errorf("unable to make ext urn from %s", referralID)) + clog.RawError(fmt.Errorf("unable to make ext urn from %s", referralID)) } extURN, err := h.Backend().AddURNtoContact(ctx, msg.Channel(), contact, referralIDExtURN, nil) if err != nil { - clog.RawError(errors.Errorf("unable to add URN %s to contact with uuid %s", extURN.String(), contact.UUID())) + clog.RawError(fmt.Errorf("unable to add URN %s to contact with uuid %s", extURN.String(), contact.UUID())) } referralFacebookURN, err := h.Backend().RemoveURNfromContact(ctx, msg.Channel(), contact, msg.URN()) if err != nil { - clog.RawError(errors.Errorf("unable to remove referral facebook URN %s from contact with uuid %s", referralFacebookURN.String(), contact.UUID())) + clog.RawError(fmt.Errorf("unable to remove referral facebook URN %s from contact with uuid %s", referralFacebookURN.String(), contact.UUID())) } } diff --git a/handlers/shaqodoon/handler.go b/handlers/shaqodoon/handler.go index 952b1ddb2..b408943a6 100644 --- a/handlers/shaqodoon/handler.go +++ b/handlers/shaqodoon/handler.go @@ -8,10 +8,11 @@ import ( "strings" "time" + "errors" + "github.com/nyaruka/courier" "github.com/nyaruka/courier/handlers" "github.com/nyaruka/gocommon/urns" - "github.com/pkg/errors" ) /* diff --git a/handlers/slack/handler.go b/handlers/slack/handler.go index 165d2df68..a61e07c6f 100644 --- a/handlers/slack/handler.go +++ b/handlers/slack/handler.go @@ -11,12 +11,13 @@ import ( "strings" "time" + "errors" + "github.com/buger/jsonparser" "github.com/nyaruka/courier" "github.com/nyaruka/courier/handlers" "github.com/nyaruka/courier/utils" "github.com/nyaruka/gocommon/urns" - "github.com/pkg/errors" ) var apiURL = "https://slack.com/api" @@ -123,7 +124,7 @@ func (h *handler) resolveFile(ctx context.Context, channel courier.Channel, file var fResponse FileResponse if err := json.Unmarshal(respBody, &fResponse); err != nil { - return "", errors.Errorf("couldn't unmarshal file response: %v", err) + return "", fmt.Errorf("couldn't unmarshal file response: %v", err) } currentFile := fResponse.File @@ -131,9 +132,9 @@ func (h *handler) resolveFile(ctx context.Context, channel courier.Channel, file if !fResponse.OK { if fResponse.Error != ErrAlreadyPublic { if fResponse.Error == ErrPublicVideoNotAllowed { - return "", errors.Errorf("public sharing of videos is not available for a free instance of Slack. file id: %s. error: %s", file.ID, fResponse.Error) + return "", fmt.Errorf("public sharing of videos is not available for a free instance of Slack. file id: %s. error: %s", file.ID, fResponse.Error) } - return "", errors.Errorf("couldn't resolve file for file id: %s. error: %s", file.ID, fResponse.Error) + return "", fmt.Errorf("couldn't resolve file for file id: %s. error: %s", file.ID, fResponse.Error) } currentFile = file } diff --git a/handlers/telegram/handler.go b/handlers/telegram/handler.go index 7d204b84e..be3a23c67 100644 --- a/handlers/telegram/handler.go +++ b/handlers/telegram/handler.go @@ -10,12 +10,13 @@ import ( "strings" "time" + "errors" + "github.com/nyaruka/courier" "github.com/nyaruka/courier/handlers" "github.com/nyaruka/courier/utils" "github.com/nyaruka/gocommon/jsonx" "github.com/nyaruka/gocommon/urns" - "github.com/pkg/errors" ) var apiURL = "https://api.telegram.org" @@ -330,12 +331,12 @@ func (h *handler) resolveFileID(ctx context.Context, channel courier.Channel, fi } if !respPayload.Ok { - return "", errors.Errorf("file id '%s' not present", fileID) + return "", fmt.Errorf("file id '%s' not present", fileID) } filePath := respPayload.Result.FilePath if filePath == "" { - return "", errors.Errorf("no 'result.file_path' in response") + return "", fmt.Errorf("no 'result.file_path' in response") } // return the URL return fmt.Sprintf("%s/file/bot%s/%s", apiURL, authToken, filePath), nil diff --git a/handlers/viber/handler.go b/handlers/viber/handler.go index ea917e8c7..7bdc61ad4 100644 --- a/handlers/viber/handler.go +++ b/handlers/viber/handler.go @@ -13,10 +13,11 @@ import ( "strconv" "strings" + "errors" + "github.com/nyaruka/courier" "github.com/nyaruka/courier/handlers" "github.com/nyaruka/gocommon/urns" - "github.com/pkg/errors" ) const ( diff --git a/handlers/vk/handler.go b/handlers/vk/handler.go index b1ed3d976..be852a8d4 100644 --- a/handlers/vk/handler.go +++ b/handlers/vk/handler.go @@ -13,13 +13,14 @@ import ( "strings" "time" + "errors" + "github.com/buger/jsonparser" "github.com/nyaruka/courier" "github.com/nyaruka/courier/handlers" "github.com/nyaruka/gocommon/httpx" "github.com/nyaruka/gocommon/jsonx" "github.com/nyaruka/gocommon/urns" - "github.com/pkg/errors" ) var ( diff --git a/handlers/wechat/handler.go b/handlers/wechat/handler.go index 0b7196471..042c5c653 100644 --- a/handlers/wechat/handler.go +++ b/handlers/wechat/handler.go @@ -14,12 +14,13 @@ import ( "sync" "time" + "errors" + "github.com/buger/jsonparser" "github.com/gomodule/redigo/redis" "github.com/nyaruka/courier" "github.com/nyaruka/courier/handlers" "github.com/nyaruka/gocommon/urns" - "github.com/pkg/errors" ) var ( diff --git a/handlers/whatsapp_legacy/handler.go b/handlers/whatsapp_legacy/handler.go index d17d37010..62b95a43b 100644 --- a/handlers/whatsapp_legacy/handler.go +++ b/handlers/whatsapp_legacy/handler.go @@ -13,6 +13,8 @@ import ( "strings" "time" + "errors" + "github.com/buger/jsonparser" "github.com/gomodule/redigo/redis" "github.com/nyaruka/courier" @@ -24,7 +26,6 @@ import ( "github.com/nyaruka/gocommon/urns" "github.com/nyaruka/redisx" "github.com/patrickmn/go-cache" - "github.com/pkg/errors" "golang.org/x/exp/maps" "golang.org/x/mod/semver" ) @@ -705,7 +706,7 @@ func buildPayloads(msg courier.MsgOut, h *handler, clog *courier.ChannelLog) ([] namespace = msg.Channel().StringConfigForKey(configNamespace, "") } if namespace == "" { - return nil, errors.Errorf("cannot send template message without Facebook namespace for channel: %s", msg.Channel().UUID()) + return nil, fmt.Errorf("cannot send template message without Facebook namespace for channel: %s", msg.Channel().UUID()) } payload := templatePayload{ diff --git a/handlers/yo/handler.go b/handlers/yo/handler.go index c541e647f..071c3349e 100644 --- a/handlers/yo/handler.go +++ b/handlers/yo/handler.go @@ -11,10 +11,11 @@ import ( "strings" "time" + "errors" + "github.com/nyaruka/courier" "github.com/nyaruka/courier/handlers" "github.com/nyaruka/gocommon/urns" - "github.com/pkg/errors" ) var ( diff --git a/sender.go b/sender.go index 80c68bc1d..a6a8e229d 100644 --- a/sender.go +++ b/sender.go @@ -6,9 +6,10 @@ import ( "log/slog" "time" + "errors" + "github.com/nyaruka/gocommon/analytics" "github.com/nyaruka/gocommon/urns" - "github.com/pkg/errors" ) type SendResult struct { diff --git a/server.go b/server.go index db512d937..b078c388a 100644 --- a/server.go +++ b/server.go @@ -15,13 +15,14 @@ import ( "sync" "time" + "errors" + "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" "github.com/nyaruka/courier/utils" "github.com/nyaruka/gocommon/analytics" "github.com/nyaruka/gocommon/httpx" "github.com/nyaruka/gocommon/jsonx" - "github.com/pkg/errors" ) // for use in request.Context diff --git a/test/backend.go b/test/backend.go index b4ba905c9..15d6f6b72 100644 --- a/test/backend.go +++ b/test/backend.go @@ -8,6 +8,8 @@ import ( "sync" "time" + "errors" + "github.com/gomodule/redigo/redis" _ "github.com/lib/pq" "github.com/nyaruka/courier" @@ -15,7 +17,6 @@ import ( "github.com/nyaruka/gocommon/httpx" "github.com/nyaruka/gocommon/urns" "github.com/nyaruka/gocommon/uuids" - "github.com/pkg/errors" ) func init() { diff --git a/test/handler.go b/test/handler.go index 564d60591..45bac850f 100644 --- a/test/handler.go +++ b/test/handler.go @@ -4,10 +4,11 @@ import ( "context" "net/http" + "errors" + "github.com/nyaruka/courier" "github.com/nyaruka/gocommon/httpx" "github.com/nyaruka/gocommon/urns" - "github.com/pkg/errors" ) func init() { From fbdc87315c51dd5f78807c98797455974ea817ce Mon Sep 17 00:00:00 2001 From: Norbert Kwizera Date: Tue, 21 May 2024 18:16:00 +0200 Subject: [PATCH 2/3] Update to latest redisx --- go.mod | 3 +-- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 0b6d29563..37833965b 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/nyaruka/ezconf v0.3.0 github.com/nyaruka/gocommon v1.55.1 github.com/nyaruka/null/v3 v3.0.0 - github.com/nyaruka/redisx v0.8.0 + github.com/nyaruka/redisx v0.8.1 github.com/patrickmn/go-cache v2.1.0+incompatible github.com/samber/slog-multi v1.0.2 github.com/samber/slog-sentry v1.2.2 @@ -48,7 +48,6 @@ require ( github.com/nyaruka/librato v1.1.1 // indirect github.com/nyaruka/null/v2 v2.0.3 // indirect github.com/nyaruka/phonenumbers v1.3.5 // indirect - github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/samber/lo v1.39.0 // indirect github.com/shopspring/decimal v1.4.0 // indirect diff --git a/go.sum b/go.sum index f4f503542..8a034cf00 100644 --- a/go.sum +++ b/go.sum @@ -81,8 +81,8 @@ github.com/nyaruka/null/v3 v3.0.0 h1:JvOiNuKmRBFHxzZFt4sWii+ewmMkCQ1vO7X0clTNn6E github.com/nyaruka/null/v3 v3.0.0/go.mod h1:Sus286RmC8P0VihFuQDDQPib/xJQ7++TsaPLdRuwgVc= github.com/nyaruka/phonenumbers v1.3.5 h1:WZLbQn61j2E1OFnvpUTYbK/6hViUgl6tppJ55/E2iQM= github.com/nyaruka/phonenumbers v1.3.5/go.mod h1:Ut+eFwikULbmCenH6InMKL9csUNLyxHuBLyfkpum11s= -github.com/nyaruka/redisx v0.8.0 h1:5QSDLfHBRFjrlTD9VaxfBbq72rb0S++Dr2ui9q/q9kY= -github.com/nyaruka/redisx v0.8.0/go.mod h1:mpTqnydmHfzeQ8V55AwS/cVrkxzHu4yGvwClEeprvbA= +github.com/nyaruka/redisx v0.8.1 h1:d9Hc8nfSKTSEU+bx+YrB13d6bzAgiiHygk4jg/Q4nb4= +github.com/nyaruka/redisx v0.8.1/go.mod h1:2TUmkDvprPInnmInR5AEbCm0zRRewkvSDVLsO+Do6iI= github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= From 2859b4ff3cf40ffe6355520e5e0de979d142c5e9 Mon Sep 17 00:00:00 2001 From: Norbert Kwizera Date: Thu, 30 May 2024 15:28:00 +0200 Subject: [PATCH 3/3] Format imports --- backends/rapidpro/backend.go | 3 +-- backends/rapidpro/status.go | 3 +-- handlers/facebook_legacy/handler.go | 3 +-- handlers/jiochat/handler.go | 3 +-- handlers/kaleyra/handler.go | 3 +-- handlers/meta/handlers.go | 3 +-- handlers/shaqodoon/handler.go | 3 +-- handlers/slack/handler.go | 3 +-- handlers/telegram/handler.go | 3 +-- handlers/viber/handler.go | 3 +-- handlers/vk/handler.go | 3 +-- handlers/wechat/handler.go | 3 +-- handlers/whatsapp_legacy/handler.go | 3 +-- handlers/yo/handler.go | 3 +-- sender.go | 3 +-- server.go | 3 +-- test/backend.go | 3 +-- test/handler.go | 3 +-- 18 files changed, 18 insertions(+), 36 deletions(-) diff --git a/backends/rapidpro/backend.go b/backends/rapidpro/backend.go index 260a9975a..91d7ffdfe 100644 --- a/backends/rapidpro/backend.go +++ b/backends/rapidpro/backend.go @@ -6,6 +6,7 @@ import ( "crypto/tls" "database/sql" "encoding/json" + "errors" "fmt" "log/slog" "net/http" @@ -18,8 +19,6 @@ import ( "sync" "time" - "errors" - "github.com/aws/aws-sdk-go/service/s3" "github.com/gomodule/redigo/redis" "github.com/jmoiron/sqlx" diff --git a/backends/rapidpro/status.go b/backends/rapidpro/status.go index e5de77cf6..b1bcb192b 100644 --- a/backends/rapidpro/status.go +++ b/backends/rapidpro/status.go @@ -3,6 +3,7 @@ package rapidpro import ( "context" "encoding/json" + "errors" "fmt" "log/slog" "os" @@ -10,8 +11,6 @@ import ( "sync" "time" - "errors" - "github.com/nyaruka/courier" "github.com/nyaruka/gocommon/dbutil" "github.com/nyaruka/gocommon/syncx" diff --git a/handlers/facebook_legacy/handler.go b/handlers/facebook_legacy/handler.go index 29e49ab8b..4cfb62f2b 100644 --- a/handlers/facebook_legacy/handler.go +++ b/handlers/facebook_legacy/handler.go @@ -3,6 +3,7 @@ package facebook_legacy import ( "bytes" "context" + "errors" "fmt" "log/slog" "net/http" @@ -10,8 +11,6 @@ import ( "strings" "time" - "errors" - "github.com/buger/jsonparser" "github.com/nyaruka/courier" "github.com/nyaruka/courier/handlers" diff --git a/handlers/jiochat/handler.go b/handlers/jiochat/handler.go index 49558513c..f37c3c997 100644 --- a/handlers/jiochat/handler.go +++ b/handlers/jiochat/handler.go @@ -6,6 +6,7 @@ import ( "crypto/sha1" "encoding/hex" "encoding/json" + "errors" "fmt" "net/http" "net/url" @@ -14,8 +15,6 @@ import ( "sync" "time" - "errors" - "github.com/buger/jsonparser" "github.com/gomodule/redigo/redis" "github.com/nyaruka/courier" diff --git a/handlers/kaleyra/handler.go b/handlers/kaleyra/handler.go index 94c76ee7a..1e4426b33 100644 --- a/handlers/kaleyra/handler.go +++ b/handlers/kaleyra/handler.go @@ -3,6 +3,7 @@ package kaleyra import ( "bytes" "context" + "errors" "fmt" "io" "mime/multipart" @@ -12,8 +13,6 @@ import ( "strings" "time" - "errors" - "github.com/buger/jsonparser" "github.com/nyaruka/courier" "github.com/nyaruka/courier/handlers" diff --git a/handlers/meta/handlers.go b/handlers/meta/handlers.go index bb431b5cd..b35a77ca0 100644 --- a/handlers/meta/handlers.go +++ b/handlers/meta/handlers.go @@ -7,6 +7,7 @@ import ( "crypto/sha256" "encoding/hex" "encoding/json" + "errors" "fmt" "net/http" "net/url" @@ -14,8 +15,6 @@ import ( "strings" "time" - "errors" - "github.com/buger/jsonparser" "github.com/nyaruka/courier" "github.com/nyaruka/courier/handlers" diff --git a/handlers/shaqodoon/handler.go b/handlers/shaqodoon/handler.go index b408943a6..d4ae6c85f 100644 --- a/handlers/shaqodoon/handler.go +++ b/handlers/shaqodoon/handler.go @@ -2,14 +2,13 @@ package shaqodoon import ( "context" + "errors" "fmt" "net/http" "net/url" "strings" "time" - "errors" - "github.com/nyaruka/courier" "github.com/nyaruka/courier/handlers" "github.com/nyaruka/gocommon/urns" diff --git a/handlers/slack/handler.go b/handlers/slack/handler.go index a61e07c6f..17ee45731 100644 --- a/handlers/slack/handler.go +++ b/handlers/slack/handler.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "encoding/json" + "errors" "fmt" "io" "mime/multipart" @@ -11,8 +12,6 @@ import ( "strings" "time" - "errors" - "github.com/buger/jsonparser" "github.com/nyaruka/courier" "github.com/nyaruka/courier/handlers" diff --git a/handlers/telegram/handler.go b/handlers/telegram/handler.go index be3a23c67..a2b31cada 100644 --- a/handlers/telegram/handler.go +++ b/handlers/telegram/handler.go @@ -3,6 +3,7 @@ package telegram import ( "context" "encoding/json" + "errors" "fmt" "net/http" "net/url" @@ -10,8 +11,6 @@ import ( "strings" "time" - "errors" - "github.com/nyaruka/courier" "github.com/nyaruka/courier/handlers" "github.com/nyaruka/courier/utils" diff --git a/handlers/viber/handler.go b/handlers/viber/handler.go index 7bdc61ad4..f593a908a 100644 --- a/handlers/viber/handler.go +++ b/handlers/viber/handler.go @@ -7,14 +7,13 @@ import ( "crypto/sha256" "encoding/hex" "encoding/json" + "errors" "fmt" "io" "net/http" "strconv" "strings" - "errors" - "github.com/nyaruka/courier" "github.com/nyaruka/courier/handlers" "github.com/nyaruka/gocommon/urns" diff --git a/handlers/vk/handler.go b/handlers/vk/handler.go index be852a8d4..ed8d6c75a 100644 --- a/handlers/vk/handler.go +++ b/handlers/vk/handler.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "encoding/json" + "errors" "fmt" "io" "mime/multipart" @@ -13,8 +14,6 @@ import ( "strings" "time" - "errors" - "github.com/buger/jsonparser" "github.com/nyaruka/courier" "github.com/nyaruka/courier/handlers" diff --git a/handlers/wechat/handler.go b/handlers/wechat/handler.go index 042c5c653..76449563c 100644 --- a/handlers/wechat/handler.go +++ b/handlers/wechat/handler.go @@ -6,6 +6,7 @@ import ( "crypto/sha1" "encoding/hex" "encoding/json" + "errors" "fmt" "net/http" "net/url" @@ -14,8 +15,6 @@ import ( "sync" "time" - "errors" - "github.com/buger/jsonparser" "github.com/gomodule/redigo/redis" "github.com/nyaruka/courier" diff --git a/handlers/whatsapp_legacy/handler.go b/handlers/whatsapp_legacy/handler.go index 62b95a43b..fad402320 100644 --- a/handlers/whatsapp_legacy/handler.go +++ b/handlers/whatsapp_legacy/handler.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "encoding/json" + "errors" "fmt" "log/slog" "net/http" @@ -13,8 +14,6 @@ import ( "strings" "time" - "errors" - "github.com/buger/jsonparser" "github.com/gomodule/redigo/redis" "github.com/nyaruka/courier" diff --git a/handlers/yo/handler.go b/handlers/yo/handler.go index 071c3349e..ef7fcf315 100644 --- a/handlers/yo/handler.go +++ b/handlers/yo/handler.go @@ -6,13 +6,12 @@ GET /handlers/yo/received/uuid?account=12345&dest=8500&message=Msg&sender=256778 import ( "context" + "errors" "net/http" "net/url" "strings" "time" - "errors" - "github.com/nyaruka/courier" "github.com/nyaruka/courier/handlers" "github.com/nyaruka/gocommon/urns" diff --git a/sender.go b/sender.go index a6a8e229d..90c54ef31 100644 --- a/sender.go +++ b/sender.go @@ -2,12 +2,11 @@ package courier import ( "context" + "errors" "fmt" "log/slog" "time" - "errors" - "github.com/nyaruka/gocommon/analytics" "github.com/nyaruka/gocommon/urns" ) diff --git a/server.go b/server.go index b078c388a..2be989524 100644 --- a/server.go +++ b/server.go @@ -4,6 +4,7 @@ import ( "bytes" "compress/flate" "context" + "errors" "fmt" "log" "log/slog" @@ -15,8 +16,6 @@ import ( "sync" "time" - "errors" - "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" "github.com/nyaruka/courier/utils" diff --git a/test/backend.go b/test/backend.go index 15d6f6b72..7141f433a 100644 --- a/test/backend.go +++ b/test/backend.go @@ -2,14 +2,13 @@ package test import ( "context" + "errors" "fmt" "log" "net/http" "sync" "time" - "errors" - "github.com/gomodule/redigo/redis" _ "github.com/lib/pq" "github.com/nyaruka/courier" diff --git a/test/handler.go b/test/handler.go index 45bac850f..f848be3f6 100644 --- a/test/handler.go +++ b/test/handler.go @@ -2,9 +2,8 @@ package test import ( "context" - "net/http" - "errors" + "net/http" "github.com/nyaruka/courier" "github.com/nyaruka/gocommon/httpx"