Skip to content

enforce validation for missing service name in registration #22381

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

Merged
merged 4 commits into from
Jun 6, 2025

Conversation

markcampv
Copy link
Contributor

@markcampv markcampv commented Jun 4, 2025

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

@markcampv markcampv requested a review from a team as a code owner June 4, 2025 21:49
@sreeram77
Copy link
Member

Hey @markcampv, thank you for the contribution. Can you please add a changelog for this PR? ref

@markcampv markcampv added the backport/all Apply backports for all active releases per .release/versions.hcl label Jun 5, 2025
@markcampv
Copy link
Contributor Author

markcampv commented Jun 5, 2025

Hey @markcampv, thank you for the contribution. Can you please add a changelog for this PR? ref

Done! I've also added a backport label since this fix is currently needed for a customer on 1.20.5+ent

Copy link
Member

@sreeram77 sreeram77 left a comment

Choose a reason for hiding this comment

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

LGTM!

@sreeram77 sreeram77 merged commit 35bc88c into hashicorp:main Jun 6, 2025
96 of 99 checks passed
@hc-github-team-consul-core hc-github-team-consul-core added backport/1.21 Changes are backported to 1.21 backport/ent/1.18 Changes are backported to 1.18 ent backport/ent/1.19 Changes are backported to 1.19 ent backport/ent/1.20 backport to ent 1.20 labels Jun 6, 2025
@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @markcampv! a backport is missing for this PR [22381] for versions [1.18,1.19,1.20,1.21] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

4 similar comments
@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @markcampv! a backport is missing for this PR [22381] for versions [1.18,1.19,1.20,1.21] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

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

📣 Hi @markcampv! a backport is missing for this PR [22381] for versions [1.18,1.19,1.20,1.21] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

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

📣 Hi @markcampv! a backport is missing for this PR [22381] for versions [1.18,1.19,1.20,1.21] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

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

📣 Hi @markcampv! a backport is missing for this PR [22381] for versions [1.18,1.19,1.20,1.21] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/all Apply backports for all active releases per .release/versions.hcl backport/ent/1.18 Changes are backported to 1.18 ent backport/ent/1.19 Changes are backported to 1.19 ent backport/ent/1.20 backport to ent 1.20 backport/1.21 Changes are backported to 1.21
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants