hashicorp / hashicorp/consul

PUT catalog register 500 error code on incorect ID field value

Open
#21,261 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
30.1k
Forks
4.6k
Avg merge
1d 18h
Merged PRs (30d)
39

Description

#### Overview of the Issue

While trying to register new entity with `PUT /catalog/register` endpoint you are allowed to provide optional ID field, its value should follow uuid format and length which is validated, but incorrect HTTP code is returned

---

#### Reproduction Steps

1. Start Consul (for example in docker)
2. Try to register new entity with `PUT /catalog/register` endpoint setting incorrect ID value: `"ID": "test"`
3. Notice `500 Internal Server Error` code with correct exception message

![image](https://github.com/hashicorp/consul/assets/39798354/c29237ea-be72-4d96-abee-d61ccfdfc79c)

#### Expected behavior

400 HTTP BAD_REQUEST should be returned

#### Full example payload
```json
{
"Datacenter": "dc1",
"ID": "test",
"Node": "t2.320",
"Address": "192.168.10.10",
"Service": {
"ID": "redis1",
"Service": "redis",
"Tags": ["primary", "v1"],
"Address": "127.0.0.1",
"TaggedAddresses": {
"lan": {
"address": "127.0.0.1",
"port": 8000
},
"wan": {
"address": "198.18.0.1",
"port": 80
}
},
"Meta": {
"redis_version": "4.0"
},
"Port": 8000
},
"Check": {
"Node": "t2.320",
"CheckID": "service:redis1",
"Name": "Redis health check",
"Notes": "Script based health check",
"Status": "passing",
"ServiceID": "redis1",
"Definition": {
"TCP": "localhost:8888",
"Interval": "5s",
"Timeout": "1s",
"DeregisterCriticalServiceAfter": "30s"
}
}
}
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing PUT /catalog/register with the provided payload and the invalid ID value "test". Trace the validation and HTTP error handling for the catalog register endpoint; done means this input returns 400 Bad Request instead of 500 Internal Server Error.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.