Skip to content

fix: filter out unpublished pages in cms_page and news_article queries#4578

Draft
marcoacierno wants to merge 2 commits intomainfrom
claude/issue-4577-20260211-1014
Draft

fix: filter out unpublished pages in cms_page and news_article queries#4578
marcoacierno wants to merge 2 commits intomainfrom
claude/issue-4577-20260211-1014

Conversation

@marcoacierno
Copy link
Member

Fixes #4577

Add live=True filter to the initial queryset in both cms_page and news_article GraphQL queries to ensure draft/unpublished pages are never returned.

Previously, unpublished pages could still be fetched by slug even though only the translated version was being filtered for live status.

Generated with Claude Code

Add live=True filter to the initial queryset in both cms_page and
news_article GraphQL queries to ensure draft/unpublished pages are
never returned. Previously, unpublished pages could still be fetched
by slug even though only the translated version was being filtered
for live status.

Fixes #4577

Co-authored-by: Marco Acierno <marcoacierno@users.noreply.github.com>
@vercel
Copy link

vercel bot commented Feb 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pycon Ready Ready Preview Feb 12, 2026 2:45pm

@claude
Copy link
Contributor

claude bot commented Feb 12, 2026

Adds live=True filter to initial queryset in both cms_page and news_article queries to prevent unpublished pages from being fetched.

Testing & Coverage: Existing tests already cover this scenario. Both test_cannot_fetch_draft_pages (cms_page.py:265) and test_cannot_get_draft_news_article (test_queries.py:181) verify that draft pages return None, confirming the fix works as expected.

No issues found.

@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.50%. Comparing base (6b43dee) to head (4111299).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4578      +/-   ##
==========================================
- Coverage   92.52%   92.50%   -0.02%     
==========================================
  Files         357      357              
  Lines       10690    10690              
  Branches      812      812              
==========================================
- Hits         9891     9889       -2     
- Misses        687      688       +1     
- Partials      112      113       +1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@marcoacierno
Copy link
Member Author

@claude update and/or write tests for this behaviour

@claude
Copy link
Contributor

claude bot commented Feb 12, 2026

Claude finished @marcoacierno's task in 2m 35s —— View job


Tests Added for Unpublished Page Filtering

  • Read changed files to understand the fix
  • Find existing tests for cms_page and news_article queries
  • Review existing tests and identify gaps
  • Write test for cms_page: base page draft, translated version live
  • Write test for news_article: base article draft, translated version live
  • Commit and push changes

Summary:

Added 2 new tests to verify the fix for filtering unpublished pages:

  1. test_cannot_fetch_draft_base_page_even_if_translation_is_live (backend/api/cms/tests/page/queries/test_cms_page.py)

    • Creates a draft base page with a live Italian translation
    • Verifies that querying for the Italian translation returns None because the base page is draft
  2. test_cannot_get_draft_base_article_even_if_translation_is_live (backend/api/cms/tests/news/test_queries.py)

    • Creates a draft base news article with a live Italian translation
    • Verifies that querying for the Italian translation returns None because the base article is draft

These tests specifically cover the bug scenario from issue #4577 where the initial queryset wasn't filtering for live=True, allowing draft base pages to be fetched when a live translation existed.
|

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.

Fix unpublished pages still being returned / visible on the website

1 participant