entur / lamassu

Mobility hub
European Union Public License 1.2
5 stars 7 forks source link

Respond with status code 502 if configured feed not yet available #432

Closed hbruch closed 2 months ago

hbruch commented 2 months ago

Summary

This PR changes the 404 to an 503 http status code reply when a requested system feed it not found but it's system_id is configured.

Issue

Closes #431 .

Unit tests

Manually verified.

hbruch commented 2 months ago

I switched to 502 BAD_GATEWAY instead of 503 SERVICE_UNAVAILABLE, as recommended by @derhuerst in personal discussion.

In case a requested feed is not found in the feedCache, GBFSV2FeedController now checks if the discovery file is available and if yes, if the requested feed is declared and hence should exist. If yes, we return http status 502.

If either the discovery file does not exist or is incomplete, we also return 502, else 404.

@testower before I continue to implement likewise test and behavior for v3, could you review, please? I.e. checking the GBFS feeds in mightOrShouldFeedExist and catching exceptions feels a bit clumsy...

testower commented 2 months ago

@hbruch added a few comments

I.e. checking the GBFS feeds in mightOrShouldFeedExist and catching exceptions feels a bit clumsy...

Maybe a way to make it feel less clumsy: https://github.com/entur/lamassu/pull/432#discussion_r1579940774 ?

hbruch commented 2 months ago

I think this PR is good for review. I implemented the same logic for all three updaters and added tests for GBFSV3FeedUpdateController and GBFSV2FeedUpdateController.