Repository navigation
Link health checks: models, checker and background task - #1
Open
sincere-arjun wants to merge 4 commits into
Open
sincere-arjun wants to merge 4 commits into
sincere-arjun wants to merge 4 commits into
Conversation
Adds the shared contract for periodic link health checks: Bookmark link_* fields and UserProfile settings (migration 0055), LD_LINK_CHECK_TIMEOUT and LD_LINK_CHECK_HOST_DELAY settings, the link_health checker service, huey tasks including the periodic scheduler, check_bookmark_links and the BookmarkSearch "broken" filter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Scheduled link health check tasks now carry a not_checked_since timestamp, so bookmarks that were checked after being scheduled are skipped instead of being checked again when the queue is backed up. Adds tests for the scheduler and task enqueueing, check_bookmark_links, the BookmarkSearch broken param and the broken query filter, and documents the LD_LINK_CHECK_TIMEOUT and LD_LINK_CHECK_HOST_DELAY options. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
record_result now writes with a queryset update instead of save(update_fields=...), so a bookmark deleted while its link is being checked no longer raises, aborts the batch and makes huey retry it (which counted failures twice for Check now). The failure count is incremented atomically with F(), so concurrent checks of the same bookmark don't lose failures. Also test that the scheduler is registered as a periodic huey task every 15 minutes, and clarify what LD_LINK_CHECK_HOST_DELAY actually limits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The public shared bookmarks API (AllowAny) built its search from the request, so ?broken=yes let anyone list which shared links are dead. query_shared_bookmarks now skips the broken filter; the owner's own active and archived queries still apply it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs: upstream linkding issue 68 (sissbruecker/linkding, not linked on purpose). This is the backend for periodic link health checks on bookmarks.
What it adds
0055_link_health):link_status_code,link_check_error,link_last_checked,link_failure_countlink_broken, which is indexedenable_link_health_checks(off by default) andlink_health_check_interval(6h / 12h / daily / weekly, default daily).LD_LINK_CHECK_TIMEOUT(default 10s) andLD_LINK_CHECK_HOST_DELAY(default 1.0s). Both can be set by environment variable and are documented indocs/src/content/docs/options.md.bookmarks/services/link_health.py):HEADrequest first and retries once with a streamedGETif that fails. Every response is closed.http_client, so the SSRF guard still applies."timeout", any other request error as"connection error".bookmarks/services/tasks.py):LD_DISABLE_BACKGROUND_TASKSis set.check_bookmark_links(bookmark_ids, current_user)only checks the user's own bookmarks and accepts ids sent as strings. It runs even when periodic checks are off.brokenparam onBookmarkSearch. It acceptsoff/yes, isn't saved as a preference, andyesshows only bookmarks withlink_broken=True.BookmarkSearchFormgets the matchingbrokenfield.Review fixes
record_resultnow writes with one database update instead ofsave(update_fields=...), which has two effects:F()), so two runs checking the same bookmark at once can't lose a failure.link_brokenis set in the same update.LD_LINK_CHECK_HOST_DELAYdocs now describe what the delay actually covers.broken: the public shared bookmarks API (/api/bookmarks/shared/, open to anonymous users) used to apply?broken=yes, so anyone could list which shared links are dead.query_shared_bookmarksnow ignores the filter; the owner's 8000 own active and archived lists still apply it. New API tests (anonymous and another signed-in user) and a queries test failed before the fix.Tests
make test: 1413 passed.make lintandruff format --check: clean.bookmarks/tests/test_link_health_tasks.pycovers:LD_DISABLE_BACKGROUND_TASKStest_bookmarks_service.py,test_bookmark_search_model.py,test_queries.pyandtest_bookmarks_api.py.Merge order
The Frontend PR (settings section, Broken filter, badge, "Check links" bulk action) and the Tests PR (checker unit tests and the e2e filter test) build on this one. Please merge this PR first.
🤖 Generated with Claude Code