bug: api backend is not resilient to ES errors

Open Beginner friendly
#2,667 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@eddy-geek is already working on this.

Since Nov 23, 2026.

  • #2699 by @eddy-geek — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
elasticsearch, python

Research direction

Start by reading web/health.py, especially _add_es_status around the reported line 79, and trace how health status is checked while serving an outing URL. Check the existing tests for health checks and Elasticsearch errors. Done means an Elasticsearch error such as a missing index is handled without preventing the API from answering the outing request.

Written by the indexing model from the issue text.

Description

follow-up to #2666 issue

An URL like https://www.camptocamp.org/outings/1964309/ should work (in degraded mode if necessary?) without ES.

instead we get

image

Error from ES like this one

api_1       | {"message": "Getting indexed docs count failed", "levelname": "ERROR", "name": "c2corg_api.web.health", "asctime": "2026-11-18 22:28:54,503", "funcName": "_add_es_status", "lineno": 82, "pathname": "/var/www/c2corg_api/web/health.py", "stack_info": null, "module": "health", "created": 1795040934.5038984, "threadName": "AnyIO worker thread", "processName": "MainProcess", "getMessage": null, "exc_info": "Traceback (most recent call last):\n  File \"/var/www/c2corg_api/web/health.py\", line 79, in _add_es_status\n    es_docs = stats['indices'][index]['total']['docs']['count']\n              ~~~~~~~~~~~~~~~~^^^^^^^\nKeyError: 'c2corg'"}

should be caught and not prevent the service from answering

Dominant language
Python
Stars
25
Forks
30
Avg merge
8h 3m
Merged PRs (30d)
255

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from c2corg/v6_api

All issues in c2corg/v6_api

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.