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

Updating server without the id key in request body results in Internal Server Error  #6828

@ericholguin

Description

@ericholguin

This Bug Report affects these Traffic Control components:

  • Traffic Ops

Current behavior:

When updating a server without the id key in the request body it will result in an Internal Server Error. Previously a user could update a server without needing the id in the request body. This issue exists for both api v3.1 and v4.0.

The same issue happens in api v3.1 when updating a server without the profile key.

HTTP/1.1 500 Internal Server Error
{
    "alerts": [
        {
            "text": "Internal Server Error",
            "level": "error"
        }
    ]
}

Expected behavior:

Should update the server and return:

HTTP/1.1 200 OK
{
    "alerts": [
        {
            "text": "Server updated",
            "level": "success"
        }
    ],
    "response": {...}
}

Steps to reproduce:

Make a PUT request to /api/4.0/servers without the id in the request body this will result in an Internal Server Error. Do the same request but add the id key in the request body and it should return a 200 OK

Comments:

Error.log: (v4)

ERROR: api.go:263: 2022-05-12T20:27:54.27204231Z: 172.20.0.11:57930 panic: (err: runtime error: invalid memory address or nil pointer dereference) stacktrace:
goroutine 39931 [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({0xd164c0, 0x1506330})
	/usr/local/go/src/runtime/panic.go:838 +0x207
github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/server.Update({0xfa4850, 0xc0062629c0}, 0xc006240a00)
	/tmp/go/src/github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/server/servers.go:1496 +0xf57

Error.log (v3)

ERROR: api.go:263: 2022-05-12T20:56:58.578411246Z: 172.20.0.11:60012 panic: (err: runtime error: invalid memory address or nil pointer dereference) stacktrace:
goroutine 57329 [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({0xd164c0, 0x1506330})
	/usr/local/go/src/runtime/panic.go:838 +0x207
github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/dbhelpers.UpdateServerProfileTableForV2V3(0x0, 0xc00143a6b0, {0xc00081ed60, 0xc}, 0xc000f42150?)
	/tmp/go/src/github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/dbhelpers/db_helpers.go:2130 +0xb4
github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/server.Update({0xfa4850, 0xc006d694a0}, 0xc006140400)
	/tmp/go/src/github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/server/servers.go:1519 +0x630

Metadata

Metadata

Assignees

No one assigned

    Labels

    Traffic Opsrelated to Traffic Opslow difficultythe estimated level of effort to resolve this issue is lowlow impactaffects only a small portion of a CDN, and cannot itself break oneregression buga bug in existing functionality introduced by a new version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions