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

Related resources

  • #...
  • #...

Checklist

Summary by Sourcery

Bug Fixes:

  • Add a check in migration 0033 to ensure obj_placeholder_field is present before modifying it to avoid errors when empty placeholder objects are absent

Copy link
Contributor

sourcery-ai bot commented Sep 15, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Migration 0033 is updated to avoid failures when placeholder records are absent by adding an explicit guard before updating placeholder references.

Flow diagram for updated placeholder migration logic in Migration 0033

flowchart TD
    A["Iterate over objects"] --> B["Check if placeholder record exists"]
    B -->|Exists| C["Update placeholder record with content_type_id and object_id"]
    B -->|Does not exist but obj_placeholder_field exists| D["Update obj_placeholder_field with content_type_id and object_id"]
    D --> E["Save obj_placeholder_field"]
Loading

File-Level Changes

Change Details Files
Added guard to skip updating when placeholder object is missing
  • Replaced unconditional else block with elif obj_placeholder_field
  • Prevented assignment on a None placeholder reference
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

@fsbraun fsbraun added the backport Commits are being back ported label Sep 15, 2025
Copy link

👋 Hi there!

Please remember to MERGE COMMIT pull requests from develop or develop-4!

Do not SQUASH commits to preserve history for the changelog.

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!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `cms/migrations/0033_placeholder_source_data_migration.py:42` </location>
<code_context>
                             object_id=obj.pk,
                         )
-                    else:
+                    elif obj_placeholder_field:
                         obj_placeholder_field.content_type_id = cur_ct_obj.pk
                         obj_placeholder_field.object_id = obj.pk
</code_context>

<issue_to_address>
Switching from 'else' to 'elif obj_placeholder_field' changes the control flow and may affect migration behavior.

Please verify that objects with a falsy 'obj_placeholder_field' do not require updates, as the new logic will skip them. Ensure all necessary cases are still covered.
</issue_to_address>

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.

@@ -39,7 +39,7 @@ def forwards(apps, schema_editor):
content_type_id=cur_ct_obj.pk,
object_id=obj.pk,
)
else:
elif obj_placeholder_field:
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: Switching from 'else' to 'elif obj_placeholder_field' changes the control flow and may affect migration behavior.

Please verify that objects with a falsy 'obj_placeholder_field' do not require updates, as the new logic will skip them. Ensure all necessary cases are still covered.

@fsbraun fsbraun merged commit c7c0b7a into release/4.1.x Sep 15, 2025
96 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Commits are being back ported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant