Skip to content

hscontrol/users: add SetUser API and CLI to update user profile fields - #3107

Open
Razano26 wants to merge 1 commit into
juanfont:mainfrom
Razano26:feat/set-user-fields
Open

hscontrol/users: add SetUser API and CLI to update user profile fields#3107
Razano26 wants to merge 1 commit into
juanfont:mainfrom
Razano26:feat/set-user-fields

Conversation

@Razano26

Copy link
Copy Markdown

Add SetUser gRPC/REST endpoint (PUT /api/v1/user/{id}) and headscale users set CLI command to update a user's display_name, email, and profile_pic_url fields.

Uses optional proto fields so only explicitly provided values are applied — omitted fields preserve their current value.

Fixes #2166

  • have read the CONTRIBUTING.md file
  • raised a GitHub issue or discussed it on the projects chat beforehand
  • added unit tests
  • added integration tests
  • updated documentation if needed
  • updated CHANGELOG.md

Add SetUser gRPC/REST endpoint (PUT /api/v1/user/{id}) and
"headscale users set" CLI command to update a user's display_name,
email, and profile_pic_url.

Uses optional proto fields so only explicitly provided values are
applied; omitted fields preserve their current value.

Fixes juanfont#2166
Copilot AI review requested due to automatic review settings February 25, 2026 13:09

Copilot AI left a comment

Copy link
Copy Markdown

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 adds the ability to update user profile fields through a new SetUser API endpoint and headscale users set CLI command. It addresses issue #2166 by allowing administrators to set display names, emails, and profile picture URLs on existing users, which enables features like tailscale whois to display user information.

Changes:

  • Add SetUser gRPC/REST endpoint (PUT /api/v1/user/{id}) with optional proto fields for partial updates
  • Add headscale users set CLI command with flags for --display-name, --email, and --picture-url
  • Comprehensive unit and integration tests covering normal operation, partial updates, validation, and error cases

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
proto/headscale/v1/user.proto Adds SetUserRequest and SetUserResponse messages with optional fields
proto/headscale/v1/headscale.proto Adds SetUser RPC endpoint with PUT HTTP binding
hscontrol/grpcv1.go Implements SetUser API with URL validation and UpdateUser state call
cmd/headscale/cli/users.go Adds setUserCmd with flag handling and validation logic
hscontrol/grpcv1_test.go Adds comprehensive unit tests for SetUser functionality
integration/cli_test.go Adds integration test verifying CLI command works end-to-end
gen/go/headscale/v1/*.go Auto-generated protobuf and gRPC code
gen/openapiv2/headscale/v1/headscale.swagger.json Auto-generated OpenAPI/Swagger documentation
CHANGELOG.md Documents the new feature

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

}

if cmd.Flags().Changed("picture-url") {
pictureURL, _ := cmd.Flags().GetString("picture-url")

Copilot AI Feb 25, 2026

Copy link

Choose a reason for hiding this comment

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

The picture URL is not validated before sending the request to the server. The createUserCmd validates the URL using url.ParseRequestURI at lines 102-105. For consistency and to provide faster feedback to users, the same validation should be added here before constructing the SetUserRequest. This would catch invalid URLs at the CLI level rather than requiring a round trip to the server.

Suggested change
pictureURL, _ := cmd.Flags().GetString("picture-url")
pictureURL, _ := cmd.Flags().GetString("picture-url")
if _, err := url.ParseRequestURI(pictureURL); err != nil {
return fmt.Errorf("invalid picture-url %q: %w", pictureURL, err)
}

Copilot uses AI. Check for mistakes.
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.

[Feature] Setting DisplayName and ProfilePicURL for headscale users

2 participants