Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError: list assignment index out of range #51

Open
dmnBrest opened this issue Sep 27, 2019 · 1 comment
Open

IndexError: list assignment index out of range #51

dmnBrest opened this issue Sep 27, 2019 · 1 comment

Comments

@dmnBrest
Copy link

dmnBrest commented Sep 27, 2019

Hello. I've just faced strange error from your lib and don't understand what is the cause and how to fix it. I have pretty simple logic to retrieve entries filtered by content_type

entries = client.entries({'content_type': 'release'})

all worked fine before and I had results from contentful. One entry had changes and I pressed "publish it" and now instead of results I see this error in console:

File "/Users/dmnbrest/Documents/Kaptio/kaptio-docs/docs-backend/pages/contentful.py", line 49, in get_categories
entries = client.entries({'content_type': 'release'})
File "/Users/dmnbrest/.local/share/virtualenvs/docs-backend-8eyOp-ef/lib/python3.7/site-packages/contentful/client.py", line 260, in entries
query
File "/Users/dmnbrest/.local/share/virtualenvs/docs-backend-8eyOp-ef/lib/python3.7/site-packages/contentful/client.py", line 580, in _get
reuse_entries=self.reuse_entries
File "/Users/dmnbrest/.local/share/virtualenvs/docs-backend-8eyOp-ef/lib/python3.7/site-packages/contentful/resource_builder.py", line 61, in build
return self._build_array()
File "/Users/dmnbrest/.local/share/virtualenvs/docs-backend-8eyOp-ef/lib/python3.7/site-packages/contentful/resource_builder.py", line 86, in _build_array
) for item in self.json['items']
File "/Users/dmnbrest/.local/share/virtualenvs/docs-backend-8eyOp-ef/lib/python3.7/site-packages/contentful/resource_builder.py", line 87, in
if not unresolvable(item, self._errors())]
File "/Users/dmnbrest/.local/share/virtualenvs/docs-backend-8eyOp-ef/lib/python3.7/site-packages/contentful/resource_builder.py", line 120, in _build_item
max_depth=self.max_depth
File "/Users/dmnbrest/.local/share/virtualenvs/docs-backend-8eyOp-ef/lib/python3.7/site-packages/contentful/resource.py", line 104, in init
self._fields = self._hydrate_fields(item, localized, includes, errors, resources=resources)
File "/Users/dmnbrest/.local/share/virtualenvs/docs-backend-8eyOp-ef/lib/python3.7/site-packages/contentful/resource.py", line 121, in _hydrate_fields
self._hydrate_non_localized_entry(fields, item, includes, errors, resources)
File "/Users/dmnbrest/.local/share/virtualenvs/docs-backend-8eyOp-ef/lib/python3.7/site-packages/contentful/resource.py", line 146, in _hydrate_non_localized_entry
resources=resources
File "/Users/dmnbrest/.local/share/virtualenvs/docs-backend-8eyOp-ef/lib/python3.7/site-packages/contentful/entry.py", line 62, in _coerce
locale=self.sys.get('locale', '*')
File "/Users/dmnbrest/.local/share/virtualenvs/docs-backend-8eyOp-ef/lib/python3.7/site-packages/contentful/content_type_field.py", line 39, in coerce
return self._coercion.coerce(value, **kwargs)
File "/Users/dmnbrest/.local/share/virtualenvs/docs-backend-8eyOp-ef/lib/python3.7/site-packages/contentful/content_type_field_types.py", line 239, in coerce
locale=locale
File "/Users/dmnbrest/.local/share/virtualenvs/docs-backend-8eyOp-ef/lib/python3.7/site-packages/contentful/content_type_field_types.py", line 221, in _coerce_block
del value['content'][node_index]
IndexError: list assignment index out of range

@dmnBrest
Copy link
Author

dmnBrest commented Sep 27, 2019

I did some debugs and here is values I have in failed method in your lib

image

image

[0, 1, 2, 3, 4, 5]

[
  {
    'data': {
      'target': {
        'sys': {
          'id': '6kF98jxmwqCjALiTroXKca',
          'type': 'Link',
          'linkType': 'Entry'
        }
      }
    },
    'content': [
      
    ],
    'nodeType': 'embedded-entry-block'
  },
  {
    'data': {
      'target': {
        'sys': {
          'id': '7KZ4bkRW6OTY2qiEPnpAIH',
          'type': 'Link',
          'linkType': 'Entry'
        }
      }
    },
    'content': [
      
    ],
    'nodeType': 'embedded-entry-block'
  },
  {
    'data': {
      'target': {
        'sys': {
          'id': 'KjnjcY3gr8um8wJHH3C2a',
          'type': 'Link',
          'linkType': 'Entry'
        }
      }
    },
    'content': [
      
    ],
    'nodeType': 'embedded-entry-block'
  },
  {
    'data': {
      'target': {
        'sys': {
          'id': '4t6wNewWa2HOMp6ePWcVw6',
          'type': 'Link',
          'linkType': 'Entry'
        }
      }
    },
    'content': [
      
    ],
    'nodeType': 'embedded-entry-block'
  },
  {
    'data': {
      'target': {
        'sys': {
          'id': '3XKrpjGuGpMAFZmnaG46Et',
          'type': 'Link',
          'linkType': 'Entry'
        }
      }
    },
    'content': [
      
    ],
    'nodeType': 'embedded-entry-block'
  },
  {
    'data': {
      'target': {
        'sys': {
          'id': '4ltSjmhNcM7lxnXPqgsBQ',
          'type': 'Link',
          'linkType': 'Entry'
        }
      }
    },
    'content': [
      
    ],
    'nodeType': 'embedded-entry-block'
  },
  {
    'data': {
      
    },
    'content': [
      {
        'data': {
          
        },
        'marks': [
          
        ],
        'value': '',
        'nodeType': 'text'
      }
    ],
    'nodeType': 'paragraph'
  }
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant