"Renaming of pipelines is not supported by this API." when attempting to call PUT /pipelines/:name

17 views
Skip to first unread message

Tina Boyce

unread,
Aug 20, 2024, 3:09:03 AMAug 20
to go-cd
Hi,

I am trying to update the pipelines and I am receiving the following 422 - Unprocessable Entity error message, "Renaming of pipelines is not supported by this API.".

I was not sure whether I am missing something vital or is it an issue so I'd thought to raise it here first.

I have a pipeline with the following details:
- group: test
- name: hi

I have done the following:
1. Do a `GET /go/api/admin/pipelines/hi` request to obtain the latest ETag value
2. Do a `PUT /go/api/admin/pipelines/hi` with the ETag value in the If-Match request header

Then I received the following error
```
{
    "message": "Renaming of pipelines is not supported by this API."
}
```

The request body for the `PUT /go/api/admin/pipelines/hi` request is:
```
{
    "group": "test",
    "pipeline": {
        "label_template": "${COUNT}",
        "lock_behavior": "lockOnFailure",
        "materials": [
            {
                "attributes": {
                    "url": "https://github.com/gocd-contrib/getting-started-repo",
                    "branch": "master",
                    "shallow_clone": true,
                    "auto_update": true
                },
                "type": "git"
            }
        ],
        "stages": [
            {
                "name": "default_stage",
                "fetch_materials": true,
                "clean_working_directory": false,
                "never_cleanup_artifacts": false,
                "approval": {
                    "type": "success",
                    "authorization": {
                        "roles": [],
                        "users": []
                    }
                },
                "environment_variables": [],
                "jobs": [
                    {
                        "name": "defaultJob",
                        "run_instance_count": null,
                        "timeout": 0,
                        "environment_variables": [],
                        "resources": [],
                        "tasks": [
                            {
                                "type": "exec",
                                "attributes": {
                                    "run_if": [
                                        "passed"
                                    ],
                                    "command": "ls",
                                    "working_directory": null
                                }
                            }
                        ],
                        "artifacts": []
                    }
                ]
            }
        ]
    }
}
```

Chad Wilson

unread,
Aug 20, 2024, 12:35:19 PMAug 20
to go...@googlegroups.com
Hiya Tina!

I think it's because your request body is missing the `name` attribute for the pipeline. When updating a pipeline config resource this should be the same as that within the URI path (i.e "hi" in your example).

The parameter is used to find the existing resource "hi" in your config. However, to determine intent and apply restrictions to what can be altered, fields within the JSON body of the config is then compared to what is currently stored on the GoCD Server. Since the names are different (null <> "hi") GoCD thinks you are trying to rename it (or remove the name!?). At this stage in the validation it ignores that you haven't actually specified the name.

https://github.com/gocd/gocd/blob/67fbd63486f5ac819c74e63996ee8ef7ba3763dd/api/api-pipeline-config-v11/src/main/java/com/thoughtworks/go/apiv11/admin/pipelineconfig/PipelineConfigControllerV11.java#L118-L123

https://github.com/gocd/gocd/blob/67fbd63486f5ac819c74e63996ee8ef7ba3763dd/api/api-pipeline-config-v11/src/main/java/com/thoughtworks/go/apiv11/admin/pipelineconfig/PipelineConfigControllerV11.java#L228-L230

Try specifying the name, e.g

{
    "group": "test",
    "name": "hi,
// ...

-Chad

--
You received this message because you are subscribed to the Google Groups "go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/go-cd/bbfb9997-0877-4abc-a8f9-5d82ef62d8dan%40googlegroups.com.

Tina Boyce

unread,
Aug 20, 2024, 6:27:43 PMAug 20
to go-cd
Thanks Chad! that did work!

Forgot to mentioned I have also tried adding "name" in the pipeline object but it didn't occurred to me to put the "name" in the pipeline config object, and that the pipeline object doesn't exist on the Edit Pipeline Configuration. I need to look harder at the example body in the https://api.gocd.org/current/#edit-pipeline-config next time.

Cheers,
Tina.

Reply all
Reply to author
Forward
0 new messages