Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions adservertargeting/requestlookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"strings"

"github.com/buger/jsonparser"
"github.com/pkg/errors"
"github.com/prebid/prebid-server/v3/openrtb_ext"
)

Expand Down Expand Up @@ -93,7 +92,7 @@ func getValueFromQueryParam(path string, queryParams url.Values) (json.RawMessag
if val != "" {
return json.RawMessage(val), nil
} else {
return nil, errors.Errorf("value not found for path: %s", path)
return nil, fmt.Errorf("value not found for path: %s", path)
}
}
return nil, nil
Expand Down
3 changes: 1 addition & 2 deletions adservertargeting/respdataprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"strings"

"github.com/pkg/errors"
"github.com/prebid/openrtb/v20/openrtb2"
"github.com/prebid/prebid-server/v3/openrtb_ext"
"github.com/prebid/prebid-server/v3/util/jsonutil"
Expand Down Expand Up @@ -170,7 +169,7 @@ func getRespData(bidderResp *openrtb2.BidResponse, field string) (string, error)
return fmt.Sprint(bidderResp.NBR.Val()), nil

default:
return "", errors.Errorf("key not found for field in bid response: %s", field)
return "", fmt.Errorf("key not found for field in bid response: %s", field)
}

}
6 changes: 3 additions & 3 deletions adservertargeting/utils.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package adservertargeting

import (
"fmt"
"strings"

"github.com/buger/jsonparser"
"github.com/pkg/errors"
"github.com/prebid/prebid-server/v3/errortypes"
"github.com/prebid/prebid-server/v3/openrtb_ext"
)
Expand Down Expand Up @@ -40,12 +40,12 @@ func typedLookup(data []byte, path string, keys ...string) ([]byte, error) {
if err != nil && err != jsonparser.KeyPathNotFoundError {
return nil, err
} else if err != nil && err == jsonparser.KeyPathNotFoundError {
return nil, errors.Errorf("value not found for path: %s", path)
return nil, fmt.Errorf("value not found for path: %s", path)
}
if verifyType(dataType) {
return value, nil
}
return nil, errors.Errorf("incorrect value type for path: %s, value can only be string or number", path)
return nil, fmt.Errorf("incorrect value type for path: %s, value can only be string or number", path)
}

func verifyType(dataType jsonparser.ValueType) bool {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ require (
github.com/lib/pq v1.10.4
github.com/mitchellh/copystructure v1.2.0
github.com/modern-go/reflect2 v1.0.2
github.com/pkg/errors v0.9.1
github.com/prebid/go-gdpr v1.12.0
github.com/prebid/go-gpp v0.2.0
github.com/prebid/openrtb/v20 v20.3.0
Expand Down Expand Up @@ -63,6 +62,7 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
Expand Down
7 changes: 3 additions & 4 deletions modules/fiftyonedegrees/devicedetection/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ package devicedetection

import (
"encoding/json"
"fmt"
"os"

"github.com/51Degrees/device-detection-go/v4/dd"
"github.com/pkg/errors"

"github.com/prebid/prebid-server/v3/util/jsonutil"
)

Expand Down Expand Up @@ -65,15 +64,15 @@ func (c *config) getPerformanceProfile() dd.PerformanceProfile {
func parseConfig(data json.RawMessage) (config, error) {
var cfg config
if err := jsonutil.UnmarshalValid(data, &cfg); err != nil {
return cfg, errors.Wrap(err, "failed to parse config")
return cfg, fmt.Errorf("failed to parse config: %w", err)
}
return cfg, nil
}

func validateConfig(cfg config) error {
_, err := os.Stat(cfg.DataFile.Path)
if err != nil {
return errors.Wrap(err, "error opening hash file path")
return fmt.Errorf("error opening hash file path: %w", err)
}

return nil
Expand Down
7 changes: 4 additions & 3 deletions modules/fiftyonedegrees/devicedetection/device_detector.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package devicedetection

import (
"fmt"

"github.com/51Degrees/device-detection-go/v4/dd"
"github.com/51Degrees/device-detection-go/v4/onpremise"
"github.com/pkg/errors"
)

type engine interface {
Expand All @@ -28,7 +29,7 @@ func newDeviceDetector(cfg *dd.ConfigHash, moduleConfig *config) (*defaultDevice
engineOptions...,
)
if err != nil {
return nil, errors.Wrap(err, "Failed to create onpremise engine.")
return nil, fmt.Errorf("failed to create onpremise engine: %w", err)
}

deviceDetector := &defaultDeviceDetector{
Expand Down Expand Up @@ -147,7 +148,7 @@ func (x defaultDeviceDetector) getSupportedHeaders() []dd.EvidenceKey {
func (x defaultDeviceDetector) getDeviceInfo(evidence []onpremise.Evidence, ua string) (*deviceInfo, error) {
results, err := x.engine.Process(evidence)
if err != nil {
return nil, errors.Wrap(err, "Failed to process evidence")
return nil, fmt.Errorf("failed to process evidence: %w", err)
}
defer results.Free()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package devicedetection

import (
"fmt"
"strconv"

"github.com/golang/glog"
"github.com/pkg/errors"
)

// deviceInfoExtractor is a struct that contains the methods to extract device information
Expand Down Expand Up @@ -61,7 +61,7 @@ func (x deviceInfoExtractor) extract(results Results, ua string) (*deviceInfo, e
geoLocation, _ := strconv.ParseBool(x.getValue(results, deviceInfoGeoLocation))
deviceId, err := results.DeviceId()
if err != nil {
return nil, errors.Wrap(err, "Failed to get device id.")
return nil, fmt.Errorf("failed to get device id: %w", err)
}
hardwareModel := x.getValue(results, deviceInfoHardwareModel)
hardwareFamily := x.getValue(results, deviceInfoHardwareFamily)
Expand Down
10 changes: 5 additions & 5 deletions modules/fiftyonedegrees/devicedetection/evidence_extractor.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package devicedetection

import (
"errors"
"fmt"
"net/http"

"github.com/51Degrees/device-detection-go/v4/onpremise"
"github.com/pkg/errors"

"github.com/51Degrees/device-detection-go/v4/dd"
"github.com/51Degrees/device-detection-go/v4/onpremise"
"github.com/prebid/prebid-server/v3/hooks/hookstage"
)

Expand Down Expand Up @@ -62,11 +62,11 @@ func (x *defaultEvidenceExtractor) extract(ctx hookstage.ModuleContext) ([]onpre

suaStrings, err := x.getEvidenceStrings(ctx[evidenceFromSuaCtxKey])
if err != nil {
return nil, "", errors.Wrap(err, "error extracting sua evidence")
return nil, "", fmt.Errorf("error extracting sua evidence: %w", err)
}
headerString, err := x.getEvidenceStrings(ctx[evidenceFromHeadersCtxKey])
if err != nil {
return nil, "", errors.Wrap(err, "error extracting header evidence")
return nil, "", fmt.Errorf("error extracting header evidence: %w", err)
}

// Merge evidence from headers and SUA, sua has higher priority
Expand Down
8 changes: 4 additions & 4 deletions modules/fiftyonedegrees/devicedetection/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package devicedetection
import (
"context"
"encoding/json"
"fmt"
"net/http"

"github.com/51Degrees/device-detection-go/v4/dd"
"github.com/51Degrees/device-detection-go/v4/onpremise"
"github.com/pkg/errors"
"github.com/prebid/prebid-server/v3/hooks/hookstage"
"github.com/prebid/prebid-server/v3/modules/moduledeps"
)
Expand Down Expand Up @@ -35,12 +35,12 @@ func configHashFromConfig(cfg *config) *dd.ConfigHash {
func Builder(rawConfig json.RawMessage, _ moduledeps.ModuleDeps) (interface{}, error) {
cfg, err := parseConfig(rawConfig)
if err != nil {
return Module{}, errors.Wrap(err, "failed to parse config")
return Module{}, fmt.Errorf("failed to parse config: %w", err)
}

err = validateConfig(cfg)
if err != nil {
return nil, errors.Wrap(err, "invalid config")
return nil, fmt.Errorf("invalid config: %w", err)
}

configHash := configHashFromConfig(&cfg)
Expand All @@ -50,7 +50,7 @@ func Builder(rawConfig json.RawMessage, _ moduledeps.ModuleDeps) (interface{}, e
&cfg,
)
if err != nil {
return nil, errors.Wrap(err, "failed to create device detector")
return nil, fmt.Errorf("failed to create device detector: %w", err)
}

return Module{
Expand Down
Loading