Skip to content

fix : resolve syntax error in backend/campaigns/tasks.py - #646

Open
Kavy-1011 wants to merge 3 commits into
Kuldeeep18:mainfrom
Kavy-1011:fix-campaigns-tasks-syntax-error
Open

fix : resolve syntax error in backend/campaigns/tasks.py#646
Kavy-1011 wants to merge 3 commits into
Kuldeeep18:mainfrom
Kavy-1011:fix-campaigns-tasks-syntax-error

Conversation

@Kavy-1011

@Kavy-1011 Kavy-1011 commented Jul 11, 2026

Copy link
Copy Markdown

Pull Request

🔗 Related Issue

Closes #341


📝 Summary of Changes

  • Fixed the syntax error in backend/campaigns/tasks.py.
  • Corrected the merged import statements.
  • Restored proper import syntax.
  • Verified that the campaigns test suite runs successfully.

🏷️ Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • ♻️ Refactor
  • 📝 Documentation update
  • 🎨 UI / Style change
  • 🔧 Chore

🧪 Testing

Steps to test:

  1. Navigate to the backend directory.
  2. Run python manage.py test campaigns.
  3. Verify that all tests pass successfully.

📸 Screenshots (if applicable)

N/A


✅ Checklist

  • No merge conflicts
  • Changes follow the project guidelines
  • Documentation updated (not applicable)
  • Related issue linked
  • Changes tested locally

Summary by CodeRabbit

  • Security / Privacy
    • Improved click-tracking redirects to rely on a single signed token (no separate destination parameter), embedding the destination in the signed payload to prevent destination swapping.
    • Added strict validation to allow only http/https destinations before redirecting.
  • New Features
    • Enhanced click analytics handling: when applicable, click timestamps update and condition-click logic can execute immediately.
  • Refactor
    • Cleanup of formatting and readability across lead processing, email sending, bounce handling, and call-step error handling.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@Kavy-1011, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 10 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 821ef5d2-ccfd-4f6e-9a3e-878a6715bda2

📥 Commits

Reviewing files that changed from the base of the PR and between e879f1e and 83dac12.

📒 Files selected for processing (2)
  • backend/campaigns/tasks.py
  • backend/campaigns/views.py
📝 Walkthrough

Walkthrough

Changes

Campaign click tracking and task maintenance

Layer / File(s) Summary
Signed click-token flow
backend/campaigns/tasks.py, backend/campaigns/views.py
Email tracking tokens now include the destination URL and redirects verify both the signature and http/https scheme before updating lead analytics and redirecting.
Campaign task maintenance
backend/campaigns/tasks.py
Campaign step formatting, CALL exception handling layout, lead-step spacing, bounce-account querying, and provider logging formatting were updated.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant EmailStep
  participant ClickTrackingView
  participant CampaignLead
  EmailStep->>EmailStep: Sign lead, step, and destination into t
  EmailStep->>ClickTrackingView: Send tracking URL with t
  ClickTrackingView->>ClickTrackingView: Verify token and destination scheme
  ClickTrackingView->>CampaignLead: Update click analytics and condition step
  ClickTrackingView-->>EmailStep: Redirect to verified destination
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR also changes click-tracking token generation and redirect validation, which are unrelated to fixing the syntax error. Move the click-tracking and redirect changes into a separate PR and keep this one limited to the import-syntax fix.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change as fixing the syntax error in backend/campaigns/tasks.py.
Linked Issues check ✅ Passed The PR objective matches issue #341 by restoring valid import syntax so campaigns/tasks.py can import successfully.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@backend/campaigns/tasks.py`:
- Around line 523-537: Update the token generation in the campaign
link-rewriting flow around token_payload and signed_token so the destination URL
is covered by the signature, and update the corresponding validation/redirect
logic in the click-tracking view to verify that same destination before
redirecting. Preserve existing handling for mailto/tel links and already-tracked
URLs, and reject tampered or otherwise invalid destinations rather than
redirecting.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ac8fd44d-62c6-485b-a95b-696999d1a9fa

📥 Commits

Reviewing files that changed from the base of the PR and between 4a33158 and 22f1eca.

📒 Files selected for processing (1)
  • backend/campaigns/tasks.py

Comment thread backend/campaigns/tasks.py Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@backend/campaigns/tasks.py`:
- Around line 532-535: Update the URL filtering logic around urlsplit in the
link-rewrite loop to require an absolute HTTP or HTTPS URL before generating a
tracking redirect. Treat empty-scheme relative URLs such as /pricing and
protocol-relative URLs such as //example.com/path as non-rewritable, while
preserving rewriting for valid HTTP(S) destinations and skipping other schemes.

In `@backend/campaigns/views.py`:
- Line 796: Update the unpacking in the payload parsing flow to explicitly mark
the unused step ID, while preserving campaign_lead_id and dest_url extraction
and the existing split limit. Use the project’s conventional throwaway variable
naming so Ruff RUF059 no longer reports the assignment.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 53b2dab3-8763-465b-b8b9-24b4c96e4da6

📥 Commits

Reviewing files that changed from the base of the PR and between 22f1eca and e879f1e.

📒 Files selected for processing (2)
  • backend/campaigns/tasks.py
  • backend/campaigns/views.py

Comment thread backend/campaigns/tasks.py Outdated
Comment thread backend/campaigns/views.py Outdated
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.

Bug: Syntax Error in backend/campaigns/tasks.py on main Branch

1 participant