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

wis2box-api when item not found should not result in ERROR and traceback #764

Open
maaikelimper opened this issue Sep 9, 2024 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@maaikelimper
Copy link
Collaborator

The wis2box-api prints and an ERROR and traceback when a user attempt to receive an item that does not exist.

I personally find this confusing as traceback makes me think something goes wrong when instead this happens every time we create a new discovery-metadata item.

Is there any way to suppress this ERROR and traceback ? The API can just return 404 when an item does not exist:

[2024-08-25T22:07:19Z] {/usr/lib/python3/dist-packages/elasticsearch/connection/base.py:288} WARNING - GET http://elasticsearch:9200/discovery-metadata/_doc/urn%3Awmo%3Amd%3Adz-meteoalgerie%3Asurface-weather-observations [status:404 request:0.002s]
[2024-08-25T22:07:19Z] {/usr/local/lib/python3.10/dist-packages/pygeoapi/provider/elasticsearch_.py:385} ERROR - NotFoundError(404, '{"_index":"discovery-metadata","_id":"urn:wmo:md:dz-meteoalgerie:surface-weather-observations","found":false}')
[2024-08-25T22:07:19Z] {/usr/local/lib/python3.10/dist-packages/pygeoapi/api/__init__.py:1393} ERROR - identifier not found
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/pygeoapi/provider/elasticsearch_.py", line 362, in get
    result = self.es.get(index=self.index_name, id=identifier)
  File "/usr/lib/python3/dist-packages/elasticsearch/client/utils.py", line 347, in _wrapped
    return func(*args, params=params, headers=headers, **kwargs)
  File "/usr/lib/python3/dist-packages/elasticsearch/client/__init__.py", line 1059, in get
    return self.transport.perform_request(
  File "/usr/lib/python3/dist-packages/elasticsearch/transport.py", line 466, in perform_request
    raise e
  File "/usr/lib/python3/dist-packages/elasticsearch/transport.py", line 427, in perform_request
    status, headers_response, data = connection.perform_request(
  File "/usr/lib/python3/dist-packages/elasticsearch/connection/http_urllib3.py", line 291, in perform_request
    self._raise_error(response.status, raw_data)
  File "/usr/lib/python3/dist-packages/elasticsearch/connection/base.py", line 328, in _raise_error
    raise HTTP_EXCEPTIONS.get(status_code, TransportError)(
elasticsearch.exceptions.NotFoundError: NotFoundError(404, '{"_index":"discovery-metadata","_id":"urn:wmo:md:dz-meteoalgerie:surface-weather-observations","found":false}')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/pygeoapi/api/itemtypes.py", line 1086, in get_collection_item
    content = p.get(
  File "/usr/local/lib/python3.10/dist-packages/pygeoapi/util.py", line 799, in get_geojsonf
    result = func(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/pygeoapi/provider/elasticsearch_.py", line 386, in get
    raise ProviderItemNotFoundError(err)
pygeoapi.provider.base.ProviderItemNotFoundError: NotFoundError(404, '{"_index":"discovery-metadata","_id":"urn:wmo:md:dz-meteoalgerie:surface-weather-observations","found":false}')
@maaikelimper maaikelimper added the bug Something isn't working label Sep 9, 2024
@maaikelimper maaikelimper added this to the sprint-016 milestone Sep 9, 2024
@tomkralidis
Copy link
Collaborator

@maaikelimper can you provide an example? 404 should be the default behaviour/response in this case.

@maaikelimper
Copy link
Collaborator Author

The snippet I provided is from the logs in wis2box-api when running our automated testing, you can reproduce the behaviour with:
python3 wis2box-ctl.py execute wis2box dataset publish /data/wis2box/metadata/discovery/dz-surface-weather-observations.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants