Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

fsbraun
Copy link
Member

@fsbraun fsbraun commented Sep 15, 2025

Description

Migration 0033 can fail if a PlaceholderField object is empty (None).

... (truncated)

self.code(from_state.apps, schema_editor)
  File "/srv/.venv/lib/python3.9/site-packages/cms/migrations/0033_placeholder_source_data_migration.py", line 43, in forwards
    obj_placeholder_field.content_type_id = cur_ct_obj.pk
AttributeError: 'NoneType' object has no attribute 'content_type_id'

Related resources

  • #...
  • #...

Checklist

Summary by Sourcery

Bug Fixes:

  • Only assign content_type_id and object_id on existing PlaceholderField objects in migration 0033 to avoid NoneType errors

@fsbraun fsbraun added needs to be backported Commits need to be backported 4.1 5.0 labels Sep 15, 2025
Copy link
Contributor

sourcery-ai bot commented Sep 15, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Migration 0033 now checks for the existence of the PlaceholderField object before updating its content_type_id and object_id, preventing NoneType AttributeErrors when placeholder entries are missing.

Class diagram for updated PlaceholderField handling in migration 0033

classDiagram
    class PlaceholderField {
        +content_type_id
        +object_id
        +save()
    }
    class Migration0033 {
        +forwards(apps, schema_editor)
    }
    Migration0033 --> PlaceholderField : updates if exists
Loading

File-Level Changes

Change Details Files
Add guard against empty PlaceholderField in migration 0033
  • Replaced unconditional else with 'elif obj_placeholder_field' to ensure updates only occur when the placeholder object exists
cms/migrations/0033_placeholder_source_data_migration.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

codecov bot commented Sep 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.71%. Comparing base (446219c) to head (7b4a64c).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8338   +/-   ##
=======================================
  Coverage   89.71%   89.71%           
=======================================
  Files         129      129           
  Lines       12750    12750           
=======================================
  Hits        11439    11439           
  Misses       1311     1311           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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.

Co-authored-by: Fabian Braun <[email protected]>
Copy link
Member

@vinitkumar vinitkumar left a comment

Choose a reason for hiding this comment

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

LGTM

@fsbraun fsbraun merged commit ed53c58 into main Sep 15, 2025
69 checks passed
@fsbraun fsbraun deleted the fix/migration-0033 branch September 15, 2025 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.1 5.0 needs to be backported Commits need to be backported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants