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 5 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?

The user agent obtained from the context metadata is propagated to thenetwork.user_agent_ext if it's empty and the CLI runs in daemon mode. The complete user agent is arduino-cli/git-snapshot arduino-ide/2.3.4 grpc-node-js/1.9.5 daemon (amd64; windows; go1.23.4) Commit:f3dc127e.

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 88.88889% with 3 lines in your changes missing coverage. Please review.

Project coverage is 67.71%. Comparing base (e9092cc) to head (527f7d2).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
commands/service_check_for_updates.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2789      +/-   ##
==========================================
+ Coverage   67.69%   67.71%   +0.01%     
==========================================
  Files         238      238              
  Lines       22388    22392       +4     
==========================================
+ Hits        15156    15163       +7     
+ Misses       6036     6034       -2     
+ Partials     1196     1195       -1     
Flag Coverage Δ
unit 67.71% <88.88%> (+0.01%) ⬆️

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
internal/cli/daemon/daemon.go Outdated Show resolved Hide resolved
internal/cli/daemon/daemon.go Outdated Show resolved Hide resolved
internal/cli/daemon/daemon.go Outdated Show resolved Hide resolved
This allows the extraction of the user-agent in a single place. Also it
forces the context passing on all operations that requires access to
network.
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.

3 participants