Skip to content

[BUG] Cannot unpublish default locale using "Bulk Locale Based unpublishing" even when default locale is the only locale published #2854

@Javimtib92

Description

@Javimtib92

Bug Description

When using the Plain Client API's bulkAction.unplublishV2 I'm geting the following error on the Bulk Action:

Image

I am pretty sure I was sending all locales in the remove.fields['*'] but just to make sure, I tried to run it on entries with only en-001 locale as "published".

⚠️ I'm omitting space id and environment id from API calls

Given the following entry:

GET https://api.eu.contentful.com/spaces/{space_id}/environments/{environment_id}/entries/049676a2-963e-44cd-9220-3b91a39a528c

{
	"metadata": {
		"tags": [],
		"concepts": []
	},
	"sys": {
		// omitted other sys fields
		"fieldStatus": {
			"*": {
				"bg-BG": "draft",
				"cs-CZ": "draft",
				"da-DK": "draft",
				"de-AT": "draft",
				"de-BE": "draft",
				"de-CH": "draft",
				"de-DE": "draft",
				"el-GR": "draft",
				"en-009": "draft",
				"en-019": "draft",
				"en-142": "draft",
				"en-150": "draft",
				"en-AU": "draft",
				"en-CA": "draft",
				"en-GB": "draft",
				"en-HK": "draft",
				"en-IE": "draft",
				"en-IN": "draft",
				"en-001": "published",
				"es-ES": "draft",
				"es-MX": "draft",
				"fi-FI": "draft",
				"fr-BE": "draft",
				"fr-CA": "draft",
				"fr-CH": "draft",
				"fr-FR": "draft",
				"ga-IE": "draft",
				"hi-IN": "draft",
				"hu-HU": "draft",
				"it-CH": "draft",
				"it-IT": "draft",
				"ja-JP": "draft",
				"ko-KR": "draft",
				"nl-BE": "draft",
				"nl-NL": "draft",
				"no-NO": "draft",
				"pl-PL": "draft",
				"pt-BR": "draft",
				"pt-PT": "draft",
				"rm-CH": "draft",
				"ro-RO": "draft",
				"ru-RU": "draft",
				"sk-SK": "draft",
				"sv-FI": "draft",
				"sv-SE": "draft",
				"tr-TR": "draft",
				"uk-UA": "draft",
				"zh-CN": "draft",
				"zh-HK": "draft",
				"zh-TW": "draft",
				"en-US": "draft"
			}
		},
		"automationTags": [],
		"contentType": {
			"sys": {
				"type": "Link",
				"linkType": "ContentType",
				"id": "introSection"
			}
		}
	},
	"fields": {
                 // omitted the fields for simplicity
	}
}

I created the following bulk action:

POST https://api.eu.contentful.com/spaces/{space_id}/environments/{environment_id}/bulk_actions

Payload:

{
  "action": "publish",
  "entities": [
    {
      "entity": {
        "sys": {
          "id": "049676a2-963e-44cd-9220-3b91a39a528c",
          "type": "Link",
          "linkType": "Entry",
          "version": 8
        }
      },
      "remove": {
        "fields": {
          "*": [
              "en-001"
          ]
        }
      }
    }
  ]
}

Then I tried to fetch the created bulk action using

GET https://api.eu.contentful.com/spaces/{space_id}/environments/{environment_id}/bulk_actions/actions/51w1GjozutXWKmdKdzIHAj

But got an error saying I have to use BulkAction.v2 which is not mentioned in your documentation.

{
	"sys": {
		"type": "Error",
		"id": "ValidationFailed"
	},
	"message": "Validation error",
	"details": {
		"errors": [
			{
				"message": "Use new API to retrieve BulkAction.v2."
			}
		]
	}
}

Following the advice,I decided to inspect the library code to find the correct endpoint and I executed:

GET https://api.eu.contentful.com/spaces/{space_id}/environments/{environment_id}/bulk_actions/51w1GjozutXWKmdKdzIHAj

And got the following response:

{
	"sys": {
		"type": "BulkAction",
		"id": "51w1GjozutXWKmdKdzIHAj",
		"schemaVersion": "BulkAction.v2",
		"createdAt": "2025-12-17T10:44:04.701Z",
		"updatedAt": "2025-12-17T10:44:05.323Z",
		"startedAt": "2025-12-17T10:44:05.216Z",
		"completedAt": "2025-12-17T10:44:05.323Z",
		"status": "failed"
	},
	"action": "publish",
	"payload": {
		"action": "publish",
		"entities": [
			{
				"entity": {
					"sys": {
						"id": "049676a2-963e-44cd-9220-3b91a39a528c",
						"type": "Link",
						"linkType": "Entry",
						"version": 8
					}
				},
				"remove": {
					"fields": {
						"*": [
							"en-001"
						]
					}
				}
			}
		]
	},
	"error": {
		"sys": {
			"type": "Error",
			"id": "BulkActionFailed"
		},
		"message": "Failed to unpublish content",
		"details": {
			"errors": [
				{
					"entity": {
						"sys": {
							"type": "Link",
							"linkType": "Entry",
							"id": "049676a2-963e-44cd-9220-3b91a39a528c"
						}
					},
					"error": {
						"sys": {
							"type": "Error",
							"id": "ValidationFailed"
						},
						"message": "Validation error",
						"details": {
							"errors": [
								{
									"name": "Invalid payload",
									"details": "The default locale (en-001) cannot be unpublished"
								}
							]
						}
					}
				}
			]
		}
	}
}

Even though I'm not able to do it through the API, the Contentful Web App allows me to unpublish manually the en-001 locale.

I'm trying to automate unpublishing invalid entries on "x" locales and I encountered this issue.

Expected Behavior

Using bulk actions I should be able to unpublish en-001 locale if all locales are being unpublished, just like in the Contentful Web App

Actual Behavior

I'm not able to unpublish en-001 locale even if it's the only locale that is published.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions