c2corg / v6_api

REST API for https://www.camptocamp.org
GNU Affero General Public License v3.0
22 stars 25 forks source link

Error when listing routes using the API #672

Open asaunier opened 7 years ago

asaunier commented 7 years ago

@Courgetteandratatouille has reported that http://api.demov6.camptocamp.org/routes?bbox=-416959,4460171,1216958,6739828&pl=fr returned an API error:

  "errors": [
    {
      "description": "please consult the server logs",
      "location": "body",
      "name": "unexpected error"
    }
  ],
  "status": "error"
}

(ditto with no param).

There is probably an integrity error with a route created using the mobile app, perhaps because of a flaw in the API validations.

The logs say:

Traceback (most recent call last):\n  
File \"/var/www/.build/venv/lib/python3.4/site-packages/c2corg_common/utils/caching.py\", line 51, in get_or_create_multi\n    should_cache_fn=should_cache_fn)\n  
File \"/var/www/.build/venv/lib/python3.4/site-packages/dogpile/cache/region.py\", line 937, in get_or_create_multi\n    new_values = creator(*keys_to_get)\n  
File \"/var/www/.build/venv/lib/python3.4/site-packages/c2corg_common/utils/caching.py\", line 113, in fn\n    raise CreatorException(exc)\nc2corg_common.utils.caching.CreatorException: 'NoneType' object has no attribute 'get'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  
File \"/var/www/.build/venv/lib/python3.4/site-packages/pyramid/tweens.py\", line 22, in excview_tween\n    response = handler(request)\n  
File \"/var/www/.build/venv/lib/python3.4/site-packages/pyramid_tm/__init__.py\", line 109, in tm_tween\n    reraise(*exc_info)\n  
File \"/var/www/.build/venv/lib/python3.4/site-packages/pyramid_tm/compat.py\", line 15, in reraise\n    raise value\n  
File \"/var/www/.build/venv/lib/python3.4/site-packages/pyramid_tm/__init__.py\", line 88, in tm_tween\n    response = handler(request)\n  
File \"/var/www/.build/venv/lib/python3.4/site-packages/pyramid/router.py\", line 158, in handle_request\n    view_name\n  
File \"/var/www/.build/venv/lib/python3.4/site-packages/pyramid/view.py\", line 547, in _call_view\n    response = view_callable(context, request)\n  File \"/var/www/.build/venv/lib/python3.4/site-packages/pyramid/config/views.py\", line 182, in __call__\n    return view(context, request)\n  
File \"/var/www/.build/venv/lib/python3.4/site-packages/pyramid/viewderivers.py\", line 393, in attr_view\n    return view(context, request)\n  
File \"/var/www/.build/venv/lib/python3.4/site-packages/pyramid/viewderivers.py\", line 371, in predicate_wrapper\n    return view(context, request)\n  
File \"/var/www/.build/venv/lib/python3.4/site-packages/pyramid/viewderivers.py\", line 442, in rendered_view\n    result = view(context, request)\n  
File \"/var/www/.build/venv/lib/python3.4/site-packages/pyramid/viewderivers.py\", line 147, in _requestonly_view\n    response = view(request)\n  
File \"/var/www/.build/venv/lib/python3.4/site-packages/cornice/service.py\", line 485, in wrapper\n    response = view_()\n  
File \"/var/www/c2corg_api/views/route.py\", line 91, in collection_get\n    return self._collection_get(ROUTE_TYPE, route_documents_config)\n  
File \"/var/www/c2corg_api/views/document.py\", line 87, in _collection_get\n    documents_config, meta_params, search_documents)\n  
File \"/var/www/c2corg_api/views/document_listings.py\", line 71, in get_documents\n    should_cache_fn=lambda v: v is not None)\n  
File \"/var/www/.build/venv/lib/python3.4/site-packages/c2corg_common/utils/caching.py\", line 55, in get_or_create_multi\n    raise creator_exception.exc\n  
File \"/var/www/.build/venv/lib/python3.4/site-packages/c2corg_common/utils/caching.py\", line 111, in fn\n    return creator(*args, **kwargs)\n  
File \"/var/www/c2corg_api/views/document_listings.py\", line 60, in get_documents_from_cache_keys\n    ids, base_query, documents_config, lang)\n  
File \"/var/www/c2corg_api/views/document_listings.py\", line 138, in _get_documents_from_ids\n    ) if doc else None for doc in documents\n  
File \"/var/www/c2corg_api/views/document_listings.py\", line 138, in <listcomp>\n    ) if doc else None for doc in documents\n  
File \"/var/www/c2corg_api/views/document_schemas.py\", line 99, in adapt_schema\n    getattr(document, type_field), field_list_type)\n  
File \"/var/www/c2corg_api/views/document_schemas.py\", line 194, in adapt_route_schema_for_activities\n    fields = get_all_fields(fields_route, activities, field_list_type)\n  
File \"/var/www/c2corg_api/views/document_schemas.py\", line 107, in get_all_fields\n    fields.get(activity).get(field_list_type) for activity in activities\n  
File \"/var/www/c2corg_api/views/document_schemas.py\", line 107, in <listcomp>\n    fields.get(activity).get(field_list_type) for activity in activities\nAttributeError: 'NoneType' object has no attribute 'get'"}

The error occuring at https://github.com/c2corg/v6_api/blob/master/c2corg_api/views/document_schemas.py#L107 https://github.com/c2corg/v6_api/blob/master/c2corg_api/views/document_schemas.py#L194

Perhaps a problem with the activities of a recently created route?

asaunier commented 7 years ago

The error message in the logs seems identical for the other problem @Courgetteandratatouille has reported with a paragliding outing of Dani http://www.demov6.camptocamp.org/outings/829274/fr/rando-vol-au-mt-charvin that might make the feed crash as well: http://api.demov6.camptocamp.org/feed?pl=fr&token=223904%2C2017-06-11T12%253A03%253A41.623385%252B00%253A00

Edit: actually the problem is not with this outing but this seems to be the last outing before the problem occured.

desnoes commented 7 years ago

On demo, it is impossible to get the list of 'hiking/trail' and 'paragliding' routes http://www.demov6.camptocamp.org/routes#act=hiking andhttp://www.demov6.camptocamp.org/routes#act=paragliding give the following error message 'unexpected error: please consult the server logs'.