Skip to content

PMM-15129 fix depguard linter issues (p1)#5494

Open
maxkondr wants to merge 2 commits into
v3from
PMM-15129-fix-linter-depguard-1
Open

PMM-15129 fix depguard linter issues (p1)#5494
maxkondr wants to merge 2 commits into
v3from
PMM-15129-fix-linter-depguard-1

Conversation

@maxkondr

Copy link
Copy Markdown
Contributor

Ticket number: PMM-15129

@maxkondr maxkondr self-assigned this Jun 11, 2026
@maxkondr maxkondr requested a review from a team as a code owner June 11, 2026 16:04
@maxkondr maxkondr requested review from a team, 4nte, JiriCtvrtka and Copilot and removed request for a team, 4nte and JiriCtvrtka June 11, 2026 16:04
@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 13.10345% with 126 lines in your changes missing coverage. Please review.
✅ Project coverage is 43.50%. Comparing base (29af54e) to head (260f0a2).

Files with missing lines Patch % Lines
managed/services/server/updater.go 0.00% 37 Missing ⚠️
managed/services/server/logs.go 4.76% 20 Missing ⚠️
managed/services/server/server.go 0.00% 18 Missing ⚠️
managed/services/supervisord/supervisord.go 12.50% 6 Missing and 1 partial ⚠️
managed/services/management/node.go 0.00% 5 Missing ⚠️
managed/services/minio/client.go 0.00% 5 Missing ⚠️
managed/services/supervisord/pmm_config.go 0.00% 5 Missing ⚠️
managed/services/telemetry/config.go 0.00% 4 Missing ⚠️
managed/services/telemetry/transform.go 33.33% 4 Missing ⚠️
managed/services/victoriametrics/prometheus.go 0.00% 4 Missing ⚠️
... and 14 more
Additional details and impacted files
@@            Coverage Diff             @@
##               v3    #5494      +/-   ##
==========================================
+ Coverage   43.46%   43.50%   +0.03%     
==========================================
  Files         413      413              
  Lines       42928    42935       +7     
==========================================
+ Hits        18659    18679      +20     
+ Misses      22393    22382      -11     
+ Partials     1876     1874       -2     
Flag Coverage Δ
admin 34.78% <ø> (ø)
agent 49.04% <ø> (+0.22%) ⬆️
managed 42.84% <11.88%> (-0.03%) ⬇️
vmproxy 72.22% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses depguard linter violations by removing usages of github.com/pkg/errors across the codebase and migrating error creation/wrapping to Go’s standard library (errors, fmt.Errorf(...%w...), errors.Join, etc.).

Changes:

  • Replaced github.com/pkg/errors wrapping/formatting with fmt.Errorf + %w (and errors.New where appropriate) across vmproxy, managed services, and QAN API.
  • Updated several call sites that relied on pkg/errors helpers (e.g., Cause, WithStack) to standard-library equivalents.
  • Adjusted a few error messages for consistency while migrating.

Reviewed changes

Copilot reviewed 37 out of 37 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
vmproxy/proxy/proxy.go Replaced errors.Wrapf with fmt.Errorf(...%w...) for filter parsing errors.
vmproxy/main.go Switched to stdlib errors.Is for http.ErrServerClosed handling.
version/parsed.go Replaced errors.Errorf with fmt.Errorf for parse failures.
utils/errors/errors.go Migrated to stdlib errors.As while keeping grpc-gateway error handling behavior.
qan-api2/utils/interceptors/interceptors.go Removed errors.Cause usage and relied on status.FromError(err).
qan-api2/models/metrics.go Replaced many errors.Wrap calls with fmt.Errorf(...%w...) and adjusted a couple messages.
qan-api2/models/data_ingestion.go Switched transactional/stmt error wrapping from pkg/errors to fmt.Errorf(...%w...).
managed/utils/validators/alerting_rules.go Migrated away from WithStack and attempted to replace errors.As logic.
managed/utils/signatures/signatures.go Replaced pkg/errors usage with stdlib errors.New.
managed/utils/pprof/pprof.go Replaced errors.Errorf with fmt.Errorf, added stdlib errors.
managed/utils/platform/client.go Replaced errors.Wrap with fmt.Errorf(...%w...) when sending telemetry.
managed/utils/interceptors/interceptors.go Removed errors.Cause usage and relied on status.FromError(err).
managed/utils/encryption/encryption.go Removed pkg/errors import in favor of stdlib errors.
managed/utils/dir/dir.go Replaced errors.Wrapf with fmt.Errorf(...%w...) for filesystem operations.
managed/services/victoriametrics/prometheus.go Replaced WithStack with contextual fmt.Errorf(...%w...).
managed/services/versioncache/versioncache.go Replaced errors.Errorf/Wrapf with errors.New / fmt.Errorf(...%w...).
managed/services/user/user.go Replaced pkg/errors import with stdlib errors.
managed/services/telemetry/transform.go Migrated errors.Errorf to errors.New / fmt.Errorf.
managed/services/telemetry/telemetry.go Replaced pkg/errors import with stdlib errors.
managed/services/telemetry/datasources.go Replaced errors.Errorf with fmt.Errorf.
managed/services/telemetry/datasource_qandb_select.go Replaced errors.Wrap with fmt.Errorf(...%w...) for DB open failures.
managed/services/telemetry/datasource_pmmdb_select.go Replaced errors.Wrap with fmt.Errorf(...%w...) for DB pool creation failures.
managed/services/telemetry/datasource_grafanadb_select.go Replaced errors.Wrap with fmt.Errorf(...%w...) for DB pool creation failures.
managed/services/telemetry/config.go Replaced errors.Wrap/Errorsf with fmt.Errorf(...%w...).
managed/services/supervisord/supervisord.go Replaced pkg/errors patterns with stdlib; adjusted supervisorctl error handling.
managed/services/supervisord/pmm_config.go Replaced Wrapf/WithStack with fmt.Errorf and errors.Join.
managed/services/server/updater.go Replaced Wrap/WithStack/Errorf with fmt.Errorf and improved log read loop error handling.
managed/services/server/server.go Replaced WithStack with contextual fmt.Errorf(...%w...); tweaked auth token read/write errors.
managed/services/server/server_test.go Replaced pkg/errors import with stdlib errors.
managed/services/server/logs.go Replaced Wrap/WithStack with fmt.Errorf(...%w...) in multiple log/zip helpers.
managed/services/scheduler/task.go Replaced errors.Errorf/WithMessage with fmt.Errorf (+ %w) and stdlib errors.
managed/services/scheduler/scheduler.go Replaced errors.Errorf with fmt.Errorf for unknown task types.
managed/services/preconditions.go Replaced Wrapf with fmt.Errorf(...%w...) for sentinel-wrapped precondition errors.
managed/services/minio/client.go Replaced WithStack/Wrapf/Errorf with fmt.Errorf / errors.Join while preserving flow.
managed/services/management/service.go Replaced errors.Wrap with fmt.Errorf(...%w...) on VM query failures.
managed/services/management/rds.go Replaced WithStack with contextual fmt.Errorf(...%w...) for AWS config load.
managed/services/management/node.go Replaced WithStack/Wrap with contextual fmt.Errorf(...%w...) for agent/node queries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 67 to 75
if err != nil {
var e *exec.ExitError
if errors.As(err, &e) && e.ExitCode() != 0 {
e, ok := errors.AsType[*exec.ExitError](err)
if ok && e.ExitCode() != 0 {
return &InvalidAlertingRuleError{
Msg: "Invalid alerting rules.",
}
}
return errors.WithStack(err)
return fmt.Errorf("alerting rule validation failed: %w", err)
}
Comment on lines 95 to 97
if config.Transform.Type != StripValuesTransform {
return nil, errors.Errorf("unspported transformation type [%s], it must be [%s]", config.Transform.Type, StripValuesTransform)
return nil, fmt.Errorf("unspported transformation type [%s], it must be [%s]", config.Transform.Type, StripValuesTransform)
}
Comment on lines 1158 to +1162
if err != nil {
if errors.Is(err, sql.ErrNoRows) {
return res, errors.New("query_id doesnt exists")
return res, errors.New("query_id doesn't exists")
}
return res, errors.Wrap(err, "failed to scan query")
return res, fmt.Errorf("failed to scan query: %w", err)
Comment on lines 1277 to 1282
if err != nil {
if errors.Is(err, sql.ErrNoRows) {
return nil, errors.Wrap(err, "query_id doesnt exists")
return nil, fmt.Errorf("query_id doesn't exists: %w", err)
}
return nil, errors.Wrap(err, "failed to scan query")
return nil, fmt.Errorf("failed to scan query: %w", err)
}
Comment on lines 655 to 656
errTX := s.db.InTransactionContext(ctx, nil, func(tx *reform.TX) error {
var err error
oldSettings, err = models.GetSettings(tx)
Comment on lines 417 to +421
b, err := cmd.Output()
return b, errors.Wrapf(err, "%s failed", cmdLine)
if err != nil {
return nil, fmt.Errorf("%s failed: %w", cmdLine, err)
}
return b, nil
return lines, newOffset - uint32(len(line)), nil
line, err = reader.ReadString('\n')
if err != nil {
if err == io.EOF {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)

}
if err == io.EOF {
err = nil
newOffset += uint32(len(line))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
G115: integer overflow conversion int -> uint32 (gosec)

err = nil
newOffset += uint32(len(line))
if newOffset-offset > up.gRPCMessageMaxSize {
return lines, newOffset - uint32(len(line)), nil

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci] reported by reviewdog 🐶
G115: integer overflow conversion int -> uint32 (gosec)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants