Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add daemon to the user agent when the CLI is started in daemon mode #2789

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

MatteoPologruto
Copy link
Contributor

@MatteoPologruto MatteoPologruto commented Dec 18, 2024

Please check if the PR fulfills these requirements

See how to contribute

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)
  • configuration.schema.json updated if new parameters are added.

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

The user agent does not specify if the CLI runs in daemon mode. It is always something like arduino-cli/git-snapshot (amd64; windows; go1.23.2) Commit:84fc413a.

What is the new behavior?

network.user_agent_ext is set too daemon when the CLI runs in daemon mode. The complete user agent is arduino-cli/git-snapshot daemon (amd64; windows; go1.23.2) Commit:84fc413a.

Does this PR introduce a breaking change, and is titled accordingly?

Other information

@MatteoPologruto MatteoPologruto added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Dec 18, 2024
@MatteoPologruto MatteoPologruto self-assigned this Dec 18, 2024
@MatteoPologruto MatteoPologruto marked this pull request as ready for review December 18, 2024 11:23
Copy link

codecov bot commented Dec 18, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 5 lines in your changes missing coverage. Please review.

Project coverage is 67.55%. Comparing base (84fc413) to head (1dc53f7).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
internal/cli/daemon/daemon.go 50.00% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2789      +/-   ##
==========================================
- Coverage   67.57%   67.55%   -0.03%     
==========================================
  Files         238      238              
  Lines       22362    22372      +10     
==========================================
+ Hits        15111    15113       +2     
- Misses       6062     6068       +6     
- Partials     1189     1191       +2     
Flag Coverage Δ
unit 67.55% <50.00%> (-0.03%) ⬇️

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

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

Copy link
Contributor

@alessio-perugini alessio-perugini left a comment

Choose a reason for hiding this comment

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

Left some comments/
It would be cool if we're able to test it.

Maybe we could use a proxy HTTP, and inspect the call that arrives are with the expected User agent. Something similar to: https://github.com/arduino/arduino-cli/blob/master/internal/cli/configuration/network_test.go#L29-L51

internal/cli/daemon/daemon.go Outdated Show resolved Hide resolved
Comment on lines +71 to +75
_, err := srv.SettingsSetValue(cmd.Context(), &rpc.SettingsSetValueRequest{
Key: "network.user_agent_ext",
ValueFormat: "cli",
EncodedValue: "daemon",
})
Copy link
Contributor

Choose a reason for hiding this comment

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

What should we do in case this value is not empty?

  1. Should we always override with the daemon value
  2. should we append to the previous value
  3. should we honor the user setting?

/cc @cmaglie

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants