Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.

/api/3.0/servers POST request with no profile key returns Internal Server Error  #6779

@ericholguin

Description

@ericholguin

This Bug Report affects these Traffic Control components:

  • Traffic Ops

Current behavior:

Making a POST request to /api/3.0/servers with no profile key in the request returns:

HTTP/1.1 500 Internal Server Error
Content-Type: application/json
Transfer-Encoding: chunked

{
    "alerts": [
        {
            "text": "Internal Server Error",
            "level": "error"
        }
    ]
}

Expected behavior:

I don't believe the profile key was required previously, however profileId has always been required. There should be no error when the profile key is missing.

Steps to reproduce:

Using the latest code from master spin up CiaB or CiaBDev and make a POST request to https://localhost:443/api/3.0/servers making sure the profile key is omitted (and all other Ids are valid):

e.g:

{
    "cachegroupId": 8,
    "cdnId": 2,
    "domainName": "test.domain.net",
    "hostName": "test-01",
    "interfaces": [
        {
            "ipAddresses": [
                {
                    "address": "0.0.0.1",
                    "gateway": "0.0.0.1",
                    "serviceAddress": true
                }
            ],
            "name": "eth0"
        }
    ],
    "physLocationId": 2,
    "profileId": 13,
    "statusId": 3,
    "typeId": 11
}

Notes:

Traffic Ops error.log will show:

ERROR: api.go:263: 2022-04-25T20:53:03.2405179Z: 172.24.0.12:44922 panic: (err: runtime error: invalid memory address or nil pointer dereference) stacktrace:
goroutine 54669 [running]:
github.com/apache/trafficcontrol/lib/go-util.Stacktrace()
	/tmp/go/src/github.com/apache/trafficcontrol/lib/go-util/util.go:32 +0x66
github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/routing/middleware.WrapPanicRecover.func1.1()
	/tmp/go/src/github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/routing/middleware/wrappers.go:173 +0x66
panic({0xd134c0, 0x1500310})
	/usr/local/go/src/runtime/panic.go:838 +0x207
github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/server.createV3(0xc001f370e0, {0xf9fef0, 0xc001ba7200}, 0xc000f3e800)
	/tmp/go/src/github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/server/servers.go:1981 +0x2cc

There should probably be a check here or maybe this should be moved elsewhere:

origProfiles := []string{*server.Profile}

Metadata

Metadata

Assignees

Labels

Traffic Opsrelated to Traffic Opshigh impactimpacts the basic function, deployment, or operation of a CDNlow difficultythe estimated level of effort to resolve this issue is lowregression buga bug in existing functionality introduced by a new version

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions