Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions api/api/utils/check_dead_links/provider_status_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@

@dataclass
class StatusMapping:
# Status codes that don't clearly indicate live/dead
unknown: tuple[int] = (429, 403)

# Status codes that indicate a working link
live: tuple[int] = (200,)

# Status codes that indicate a dead link (should be filtered out)
dead: tuple[int] = (404, 410, 451, 500, 502, 503, 504)


provider_status_mappings = defaultdict(
StatusMapping,
Expand Down
5 changes: 5 additions & 0 deletions api/test/unit/utils/test_check_dead_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,8 @@ def test_mset_and_expire_for_responses(is_cache_reachable, cache_name, request):
"Redis connect failed, cannot cache link liveness.",
]
)

def test_410_status_is_marked_as_dead():
from api.utils.check_dead_links.provider_status_mappings import StatusMapping
mapping = StatusMapping()
assert 410 in mapping.dead
Loading