Skip to content

fix(deploy): resolve server-group names passed to -s/--server (DHQ-586)#11

Merged
facundofarias merged 1 commit into
mainfrom
fix/dhq-586-deploy-resolve-group-name
May 22, 2026
Merged

fix(deploy): resolve server-group names passed to -s/--server (DHQ-586)#11
facundofarias merged 1 commit into
mainfrom
fix/dhq-586-deploy-resolve-group-name

Conversation

@facundofarias
Copy link
Copy Markdown
Contributor

@facundofarias facundofarias commented May 22, 2026

Summary

  • dhq deploy -s \"<group name>\" was documented as supported (deployhq.com/support/cli/cli-deploying) but only worked when a UUID was passed; a display name fell through to the server-only resolver and either triggered the interactive picker or failed with "Multiple servers found" in non-interactive mode.
  • Adds a resolveGroupName helper mirroring resolveServerName's exact / normalized / contains tiers, and tries it as a fallback before falling back to the server picker.
  • On a unique group match the group's identifier is used as parent_identifier and resolvedServer stays nil — downstream code already tolerates this (GetServer 404s for groups; see existing comments at deploy.go:40 and :325).
  • Refs DHQ-586 — Fernand conversation #600430.

Test plan

  • go test ./... — 6 new unit tests for resolveGroupName (exact, case-insensitive, normalized, contains, ambiguous, no-match) all pass; existing suite still green
  • golangci-lint run — clean
  • Live smoke: pick a project with a server group, run dhq deploy -p <project> -s \"<group name>\" --dry-run --json, confirm parent_identifier in the request matches the group identifier (not a server)
  • Live smoke (negative): server name with the same prefix as a group still wins (servers checked first); a name that matches neither still shows the existing picker / error

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced deploy command with improved server-group resolution, supporting multiple matching strategies (exact, case-insensitive, normalized, and substring matching) for greater flexibility in deployment operations.
  • Tests

    • Added comprehensive test coverage for server-group name resolution functionality, including various matching scenarios and edge cases.

Review Change Stack

dhq deploy -s "<group name>" was documented as supported but only
worked when the group's UUID was passed; a display name fell through
to the server-only resolver and triggered the picker or "Multiple
servers found" error in non-interactive mode.

Add a resolveGroupName helper mirroring resolveServerName's exact /
normalized / contains tiers, and try it as a fallback in runDeploy
before showing the server picker. On a unique group match, the group's
identifier is used as parent_identifier and resolvedServer stays nil —
downstream code already tolerates this (GetServer 404s for groups).

Refs DHQ-586.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@linear
Copy link
Copy Markdown

linear Bot commented May 22, 2026

DHQ-586

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

Walkthrough

This PR adds server-group name resolution to the deploy command. It introduces a resolveGroupName function that matches group names using a three-tier strategy (exact, normalized, contains), integrates it into the server argument resolution flow to fall back to group matching when direct server matching fails, and includes comprehensive unit tests validating the matching behavior.

Changes

Server-group resolution feature

Layer / File(s) Summary
Group name resolution logic
internal/commands/deploy.go
resolveGroupName function implements exact/normalized/contains-tier matching against server-group display names, returning both identifier and display name on unique match or empty strings on ambiguity or no match.
Deploy command integration
internal/commands/deploy.go
Added matched flag to track server-name resolution success, then reworked --server argument resolution in newDeployCmd to attempt group-name matching when direct server matching fails, updating display and state before falling back to candidate-server ambiguity handling.
Unit tests
internal/commands/deploy_test.go
Test cases for resolveGroupName validating exact display-name matching, case-insensitive matching, normalized matching, substring matching, ambiguous-match behavior, and no-match behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding server-group name resolution to the deploy command's -s/--server flag, including the specific issue reference (DHQ-586).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/dhq-586-deploy-resolve-group-name

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
internal/commands/deploy_test.go (1)

303-356: ⚡ Quick win

Add one deploy-flow test for server-precedence then group fallback wiring.

These tests cover resolveGroupName well, but they don’t verify the actual deploy command path (server-name precedence, then group fallback setting parent_identifier behavior). A single httptest.NewServer-backed command test here would lock in DHQ-586 behavior and prevent regressions.

As per coding guidelines, "Use Go unit tests with httptest.NewServer for recorded response shapes and integration_test.go for validating types against real API JSON (golden tests)."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/commands/deploy_test.go` around lines 303 - 356, Add a new unit test
in deploy_test.go that exercises the deploy command end-to-end using
httptest.NewServer to assert server-name precedence over group fallback and that
when a group is used the request payload includes parent_identifier;
specifically, invoke the CLI deploy code path (the same helper/tests that call
the deploy command) with a mock API server that records incoming requests,
assert that when both --server and --group are provided the server identifier is
used, and in the fallback case (no server) the deployed server's POST/PUT
contains parent_identifier set to the resolved group's Identifier (use
resolveGroupName to derive expected values and inspect the request body from the
httptest server).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@internal/commands/deploy_test.go`:
- Around line 303-356: Add a new unit test in deploy_test.go that exercises the
deploy command end-to-end using httptest.NewServer to assert server-name
precedence over group fallback and that when a group is used the request payload
includes parent_identifier; specifically, invoke the CLI deploy code path (the
same helper/tests that call the deploy command) with a mock API server that
records incoming requests, assert that when both --server and --group are
provided the server identifier is used, and in the fallback case (no server) the
deployed server's POST/PUT contains parent_identifier set to the resolved
group's Identifier (use resolveGroupName to derive expected values and inspect
the request body from the httptest server).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f0652ee4-c2d3-4b60-9b0c-141db582f788

📥 Commits

Reviewing files that changed from the base of the PR and between 7a1b6b3 and bef2706.

📒 Files selected for processing (2)
  • internal/commands/deploy.go
  • internal/commands/deploy_test.go

@facundofarias facundofarias merged commit efc48a9 into main May 22, 2026
3 checks passed
@facundofarias facundofarias deleted the fix/dhq-586-deploy-resolve-group-name branch May 22, 2026 08:30
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.

1 participant