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

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

Merged
merged 6 commits into from May 3, 2024

Conversation

hbruch
Copy link
Collaborator

@hbruch hbruch commented Apr 20, 2024

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.

Copy link
Collaborator

@testower testower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if system_id is well known and feed is a required one

Do you mean required by the spec? This case is not checked in the implementation though. And wouldn't it be more appropriate to check that it is present in the discovery file?

@testower testower added this to the 1.1 (next release) milestone Apr 25, 2024
@hbruch hbruch marked this pull request as draft April 25, 2024 17:19
@hbruch
Copy link
Collaborator Author

hbruch commented Apr 25, 2024

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
Copy link
Collaborator

@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: #432 (comment) ?

@hbruch hbruch changed the title Respond with status code 503 if configured feed not yet available Respond with status code ~~503~~502 if configured feed not yet available Apr 26, 2024
@hbruch hbruch changed the title Respond with status code ~~503~~502 if configured feed not yet available Respond with status code ~~503~~ 502 if configured feed not yet available Apr 26, 2024
@hbruch hbruch changed the title Respond with status code ~~503~~ 502 if configured feed not yet available Respond with status code 502 if configured feed not yet available Apr 26, 2024
@hbruch hbruch force-pushed the issues/431_service_unavailable branch from e4b8516 to 1b3a164 Compare April 26, 2024 14:01
@hbruch hbruch marked this pull request as ready for review May 2, 2024 10:16
@hbruch
Copy link
Collaborator Author

hbruch commented May 2, 2024

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

@testower testower merged commit 1591a84 into entur:master May 3, 2024
2 checks passed
github-actions bot pushed a commit that referenced this pull request May 3, 2024
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

Successfully merging this pull request may close these issues.

Return 503 for not yet available feeds instead of 404
2 participants