contentful-migration icon indicating copy to clipboard operation
contentful-migration copied to clipboard

Misleading `SpaceAccessError` shown during failed request (Response size too big)

Open yan-kisen opened this issue 3 years ago • 4 comments

Migration script throws a SpaceAccessError for all Request errors.

The provided space does not exist or you do not have access.

One of my ContentTypes was returning a Response size too big error during the migration-parser initialization.

https://github.com/contentful/contentful-migration/blob/168c7f2c02aab2caa3ac595c2dd136e2ed7609a0/src/lib/migration-parser.ts#L109-L114

After a lot of head scratching, the root cause was finally identified as coming from this response

{
  "sys": {
    "type": "Error",
    "id": "BadRequest"
  },
  "message": "Response size too big. Maximum allowed response size: 7340032B.",
  "requestId": "9be0607d-fabc-4c6c-8cfb-99234ea45eec"
}

Expected Behavior

Provide more accurate exception information. (Pass the caught error upstream)

Workaround

In my case, I was able to get it to work by modifying the requestBatchSize argument

--requestBatchSize=50

yan-kisen avatar Oct 20 '21 16:10 yan-kisen

Got the same error, I had to dive in the code to find what was happening. I used the same fix in a migration node script if anyone needs this outside of the CLI:

const options = {
  migrationFunction: '...',
  spaceId: '...',
  accessToken: '...',
  environmentId: 'env',

  requestBatchSize: 50
}

await runMigration(options)

Would be really nice to have a better error message.

PierreCavalet avatar Feb 14 '22 14:02 PierreCavalet

Same for me.

This really should be improved, since it took me a while to find the real problem by digging into the code.

It would be really cool, when there would be an automatic retry with a reduced batch size when the Response size to big error is hit. Unfortunately the status code is a normal 400 Bad Request. With that you would have to check the error message to find out that the response size would be too big. Maybe the API can also be improved to make such things easier.

tharders avatar Oct 10 '22 14:10 tharders

Just for anyone else who ends up here, I got this same error, but for something completely different. It seems like this error maybe a common output from multiple different errors when it's trying to interact with Contentful.

In my use case, it was trying to find a content entry that didn't exist.

gigaSproule avatar Nov 03 '23 16:11 gigaSproule

I just ran into the issue SpaceAccessError and spent some time troubleshooting to find the real reason was Response size too big. Maximum allowed response size: 7340032B.. Just documenting to give this issue a bump for the next user.

jalandis avatar Jul 08 '24 17:07 jalandis