Skip to content

chore: remove unnecessary Error() calls#4031

Merged
dd-mergequeue[bot] merged 3 commits into
DataDog:mainfrom
mdb:mdb/remove-redundant-error-call
Oct 9, 2025
Merged

chore: remove unnecessary Error() calls#4031
dd-mergequeue[bot] merged 3 commits into
DataDog:mainfrom
mdb:mdb/remove-redundant-error-call

Conversation

@mdb

@mdb mdb commented Oct 7, 2025

Copy link
Copy Markdown
Contributor

What does this PR do?

This is a NOOP cosmetic change that seeks to improve the developer experience (for contributors, as well as for users who vendor dd-trace-go).

In fmt.Errorf calls, the %s verb already calls Error() on error types, making the explicit call unnecessary. Tools like Cursor Bug Bot (and probably some editor tools too) complain about the redundant Error() calls; this satisfies the complaints.

...it also means users who vendor DataDog/dd-trace-go and who use Cursor Bug Bot (or other code review automation tools) aren't subjected to these tools' complaints about the redundant Error() calls littering pull requests. So, this helps minimize that litter.

Motivation

My organization vendors dd-trace-go in our own codebase(s); this improves the developer experience, particular around dd-trace-go upgrades.

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • New code is free of linting errors. You can check this by running ./scripts/lint.sh locally.
  • [] Add an appropriate team label so this PR gets put in the right place for the release notes.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild.

@mdb
mdb requested review from a team as code owners October 7, 2025 10:57
@mdb
mdb requested review from anmarchenko and mtoffl01 October 7, 2025 10:57
@darccio

darccio commented Oct 7, 2025

Copy link
Copy Markdown
Member

Hi @mdb, thanks for reaching out. The Error() calls are required by design to avoid PII leakages, as explained on #3706.

Although we are open to review this approach, we think that calling Error() states a clear intent instead of relying on %s or %v.

@nsrip-dd nsrip-dd 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.

Profiling changes LGTM. Thanks!

Comment thread internal/hostname/azure/azure.go Outdated
@nsrip-dd

nsrip-dd commented Oct 7, 2025

Copy link
Copy Markdown
Contributor

Hi @mdb, thanks for reaching out. The Error() calls are required by design to avoid PII leakages, as explained on #3706.

@darccio if I'm not mistaken, that's specifically for log calls, right? Whereas it seems like this PR just touches calls to fmt.Errorf, and the fmt docs say explicitly that "If an operand implements the error interface, the Error method will be invoked to convert the object to a string, which will then be formatted as required by the verb (if any)."

@kakkoyun kakkoyun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

Thanks for cleaning it up.

@kakkoyun

kakkoyun commented Oct 7, 2025

Copy link
Copy Markdown
Member

Hi @mdb, thanks for reaching out. The Error() calls are required by design to avoid PII leakages, as explained on #3706.

@darccio if I'm not mistaken, that's specifically for log calls, right? Whereas it seems like this PR just touches calls to fmt.Errorf, and the fmt docs say explicitly that "If an operand implements the error interface, the Error method will be invoked to convert the object to a string, which will then be formatted as required by the verb (if any)."

This is my sloppiness. The original PR introduced in a haste as a response to an incident. Sorry about this. The original version was forcing to call Error() when %v is specified. Then I decided to change the strategy and we started to force usage %s as verb. However, I was lazy to remove Error() calls introduced.

This is a NOOP cosmetic change that seeks to improve the developer
experience (for contributors, as well as for users who vendor
dd-trace-go).

In fmt.Errorf calls, the %s verb already calls Error() on error types, making
the explicit call unnecessary. Tools like Cursor Bug Bot (and probably some editor
tools too) complain about the redundant Error() calls; this satisfies the complaints.

...it also means users who vendor `DataDog/dd-trace-go` and who use
Cursor Bug Bot (or other code review automation tools) aren't subjected
to these tools' complaints about the redundant Error() calls littering
pull requests.

Signed-off-by: Mike Ball <[email protected]>
@mdb
mdb force-pushed the mdb/remove-redundant-error-call branch from 23c803d to 05ac9d6 Compare October 7, 2025 12:32
@darccio

darccio commented Oct 8, 2025

Copy link
Copy Markdown
Member

/merge -h

@dd-devflow-routing-codex

dd-devflow-routing-codex Bot commented Oct 8, 2025

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2025-10-08 13:27:49 UTC ℹ️ Start processing command /merge -h


2025-10-08 13:27:50 UTC ℹ️ Help: merge

Add the current pull request in a queue to be processed and merged

  • -c, --cancel Cancel the previous merge command
  • -@, --delay string Date expression for scheduling the merge of this pull request.
    Examples: -@ in 3 hours, -@ at midnight, -@ tomorrow at 8am CET
    See https://datadoghq.atlassian.net/wiki/spaces/DEVX/pages/3451160252/All+Devflow+actions#Time-expressions for more details.
  • -d, --deploy Deploy services after merge, try to autodetect services if none specified
  • -h, --help Display help for this command
  • -m, --method string Merge method [default|merge|rebase|squash] (default "default")
  • -p, --priority string Priority of the pull request [low|medium|urgent|incident] (default "medium")
  • --reason string Reason for skipping checks
  • -s, --service strings Services to deploy (default [])
  • -t, --target string Target to use when triggering the post merge deployement, we will try to autodetect the target for the branch if none specified

Examples:

  • Add the current pull request in a queue to be processed and merged:
merge
  • Add the current pull request in a queue to be processed and merged with an urgent priority, meaning it will be processed before all other PRs:
merge -p urgent
  • Add the current pull request in a queue to be processed and merged with an incident priority, meaning it will remove all other PRs from the queue so it can be processed immediately:
merge -p incident
  • Deploy the impacted services after merge (triggering conductor):
merge -d
  • Process the current pull request in a queue to be processed and merged at 10am CET:
merge -@ 10am CET

@darccio

darccio commented Oct 9, 2025

Copy link
Copy Markdown
Member

/merge

@dd-devflow-routing-codex

dd-devflow-routing-codex Bot commented Oct 9, 2025

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2025-10-09 09:27:16 UTC ℹ️ Start processing command /merge


2025-10-09 09:27:25 UTC ℹ️ MergeQueue: waiting for PR to be ready

This merge request is not mergeable yet, because of pending checks/missing approvals. It will be added to the queue as soon as checks pass and/or get approvals.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2025-10-09 09:34:18 UTC ℹ️ MergeQueue: merge request added to the queue

The expected merge time in main is approximately 18m (p90).


2025-10-09 09:46:03 UTC ℹ️ MergeQueue: This merge request was merged

@dd-mergequeue
dd-mergequeue Bot merged commit 6eb51be into DataDog:main Oct 9, 2025
131 checks passed
@mdb
mdb deleted the mdb/remove-redundant-error-call branch October 9, 2025 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants