Skip to content

Backport of enforce validation for missing service name in registration into release/1.21.x #22387

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

Open
wants to merge 2 commits into
base: release/1.21.x
Choose a base branch
from

Conversation

hc-github-team-consul-core
Copy link
Collaborator

Backport

This PR is auto-generated from #22381 to be assessed for backporting due to the inclusion of the label backport/1.21.

🚨

Warning automatic cherry-pick of commits failed. If the first commit failed,
you will see a blank no-op commit below. If at least one commit succeeded, you
will see the cherry-picked commits up to, not including, the commit where
the merge conflict occurred.

The person who merged in the original PR is:
@sreeram77
This person should manually cherry-pick the original PR into a new backport PR,
and close this one when the manual backport PR is merged in.

merge conflict error: unable to process merge commit: "bc526e57ec0ba48818e279e235512a4380570379", automatic backport requires rebase workflow

The below text is copied from the body of the original PR.


Description

Adds validation to the catalog register endpoint to ensure that a service name (Service.Service) is provided when registering a service. This prevents registrations with empty service names, which resulted in the Services page in the Consul UI being broken.

If both Service.ID and Service.Service are empty, the API now returns an error message.

Testing & Reproduction steps

  • Added unit test TestCatalog_Register_RejectsMissingServiceName in catalog_endpoint_test.go
  • Manually validated behavior using:
curl -X PUT http://localhost:8500/v1/catalog/register \
  -H "Content-Type: application/json" \
  --data-raw '{
    "Datacenter": "dc1",
    "Node": "my_node",
    "Address": "123.456.78.9",
    "Service": {
      "ID": "",
      "Service": "",
      "Port": 9001
    }
  }'

service name (Service.Service) is required; both Service ID (Service.ID) and Service Name cannot be empty

Links

PR Checklist

  • [x ] updated test coverage
  • external facing docs updated
  • appropriate backport labels added
  • [x ] not a security concern

Overview of commits

Copy link
Collaborator

Choose a reason for hiding this comment

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

Auto approved Consul Bot automated PR

Copy link
Contributor

@markcampv markcampv left a comment

Choose a reason for hiding this comment

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

LGTM

@markcampv markcampv marked this pull request as ready for review June 6, 2025 16:35
@markcampv markcampv requested a review from a team as a code owner June 6, 2025 16:35
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.

4 participants