caddyserver/caddy · error · APIError

request path is missing object ID

Error message

request path is missing object ID

What it means

Thrown by Caddy's admin API handleConfigID handler when a request to the /id/ endpoint has a path with no object ID after the prefix. The handler splits r.URL.Path on '/' and requires at least three parts with a non-empty third segment. It returns HTTP 400 with the message 'request path is missing object ID'.

Source

Thrown at admin.go:1098

	default:
		return APIError{
			HTTPStatus: http.StatusMethodNotAllowed,
			Err:        fmt.Errorf("method %s not allowed", r.Method),
		}
	}

	return nil
}

func handleConfigID(w http.ResponseWriter, r *http.Request) error {
	idPath := r.URL.Path

	parts := strings.Split(idPath, "/")
	if len(parts) < 3 || parts[2] == "" {
		return APIError{
			HTTPStatus: http.StatusBadRequest,
			Err:        fmt.Errorf("request path is missing object ID"),
		}
	}
	if parts[0] != "" || parts[1] != "id" {
		return APIError{
			HTTPStatus: http.StatusBadRequest,
			Err:        fmt.Errorf("malformed object path"),
		}
	}
	id := parts[2]

	// map the ID to the expanded path
	rawCfgMu.RLock()
	expanded, ok := rawCfgIndex[id]
	rawCfgMu.RUnlock()
	if !ok {
		return APIError{
			HTTPStatus: http.StatusNotFound,
			Err:        fmt.Errorf("unknown object ID '%s'", id),

View on GitHub (pinned to 50e54ee279)

Solutions

  1. Append the actual object ID (its @id field from the config) after /id/, e.g. GET http://localhost:2019/id/my-route
  2. First GET /config/ or the raw config JSON to find the @id value you meant to reference
  3. If you do not need ID-based addressing, use the canonical /config/... path instead

Example fix

# before
curl http://localhost:2019/id/
# after
curl http://localhost:2019/id/httpserver/routes/0
Defensive patterns

Strategy: validation

Validate before calling

# Validate the URL has a non-empty ID before calling
req_url="http://localhost:2019/id/${OBJ_ID:?OBJ_ID must be set}"
curl -f "$req_url"

Prevention

When it happens

Trigger: Any HTTP request to the admin endpoint whose path is exactly '/id/' or '/id' (e.g. curl http://localhost:2019/id/ or GET /id). Requests that use the ID-based config path form but forget to append the @id value.

Common situations: Scripts or tooling that build the /id/<ID> URL dynamically and pass an empty ID variable; copy-paste from docs that omit the placeholder; clients that URL-trim the trailing ID.

Related errors


AI-assisted analysis of caddyserver/caddy@50e54ee279 (2026-08-15). Data as JSON: /api/errors/851db237529080f2. Report an issue: GitHub.