kubesphere/kubesphere · error

the name of the object

Error message

the name of the object (%s) does not match the name on the URL (%s)

What it means

UpdateWorkspaceTemplate validates that the name in the submitted workspace object body matches the workspaceName path parameter. Kubernetes semantics require these to be equal; a mismatch means the client is trying to update a different object than the URL addresses, so the handler returns 400 with 'the name of the object (%s) does not match the name on the URL (%s)'.

Solutions

  1. Ensure body metadata.name exactly equals the URL workspace segment before issuing the PUT
  2. Refetch the object from the same workspace you intend to update
  3. To rename a workspace, create a new one and migrate instead of changing metadata.name
  4. Fix template/tooling that interpolates the URL path but not the body name

Example fix

// before
body := {"metadata":{"name":"workspace-a"}} // URL: /workspaces/workspace-b
// after
body := {"metadata":{"name":"workspace-b"}} // matches URL /workspaces/workspace-b
Defensive patterns

Strategy: validation

Validate before calling

func checkWorkspaceUpdate(urlName string, obj metav1.Object) error {
	if obj.GetName() != urlName {
		return fmt.Errorf("body name %q != URL name %q", obj.GetName(), urlName)
	}
	return nil
}
// call before issuing PUT

Try / catch

if err := checkWorkspaceUpdate(wsName, workspace); err != nil { return err }
// server already returns 400 on mismatch; treat 400 with 'does not match the name on the URL' as a client bug, not retryable
if resp.StatusCode == 400 && strings.Contains(body, "does not match the name on the URL") {
	return fmt.Errorf("fix client payload: %s", body)
}

Prevention

When it happens

Trigger: PUT /kapis/tenant.kubesphere.io/v1beta1/workspaces/{workspace} where the JSON body's metadata.name differs from {workspace} (e.g. body fetched from another workspace, or name edited in a UI form).

Common situations: Copying a workspace spec and forgetting to change metadata.name; GET from workspace-A then PUT against workspace-B; renaming attempts (renames are not allowed via PUT); templating bugs where the URL uses a variable but the body is hardcoded.

Related errors


AI-assisted analysis of kubesphere/kubesphere@04a29b5c60 (2026-09-03). Data as JSON: /api/errors/0c277dcff4943117. Report an issue: GitHub.

Appendix: source

Thrown at pkg/kapis/tenant/v1beta1/handler.go:139

	}

	_ = response.WriteEntity(servererr.None)
}

func (h *handler) UpdateWorkspaceTemplate(req *restful.Request, resp *restful.Response) {
	workspaceName := req.PathParameter("workspace")
	var workspace tenantv1beta1.WorkspaceTemplate

	err := req.ReadEntity(&workspace)

	if err != nil {
		klog.Error(err)
		api.HandleBadRequest(resp, req, err)
		return
	}

	if workspaceName != workspace.Name {
		err := fmt.Errorf("the name of the object (%s) does not match the name on the URL (%s)", workspace.Name, workspaceName)
		klog.Errorf("%+v", err)
		api.HandleBadRequest(resp, req, err)
		return
	}

	requestUser, ok := request.UserFrom(req.Request.Context())
	if !ok {
		err := fmt.Errorf("cannot obtain user info")
		klog.Errorln(err)
		api.HandleForbidden(resp, req, err)
	}

	updated, err := h.tenant.UpdateWorkspaceTemplate(requestUser, &workspace)

	if err != nil {
		klog.Error(err)
		if errors.IsNotFound(err) {
			api.HandleNotFound(resp, req, err)

View on GitHub (pinned to 04a29b5c60)