Skip to content

fix(api): update unique constraint for Provider model to exclude soft… - #9054

Merged
AdriiiPRodri merged 8 commits into
masterfrom
PROWLER-290-allow-multiple-provider-uid-when-they-are-deleted
Nov 7, 2025
Merged

AdriiiPRodri merged 8 commits into
masterfrom
PROWLER-290-allow-multiple-provider-uid-when-they-are-deleted

Conversation

@rakan-pro

@rakan-pro rakan-pro commented Oct 29, 2025

Copy link
Copy Markdown
Contributor

Context

This change addresses an issue where attempting to soft-delete a provider that was already soft-deleted would result in a duplicate error.

Description

This change modifies the unique constraint on the Provider model to ensure that it only considers non-deleted entries.
A new migration has been created to reflect this change in the database schema.
Additionally, tests have been added to verify the behavior of soft deletion and the uniqueness of provider entries.

Steps to review

  1. Manual Verification (if possible): If there's an easy way to spin up the API locally, consider:
    • Creating a provider.
    • Soft-deleting that provider.
    • Attempting to create a new provider with the same unique identifier (tenant_id, provider, uid). This should succeed.
    • Attempting to create a new provider with the same unique identifier when the original is NOT soft-deleted. This should fail.
    • Soft-deleting that provider. should not fail (it was failing before due to the UniqueConstraint)

Checklist

API

  • Verify if API specs need to be regenerated.
  • Check if version updates are required (e.g., specs, Poetry, etc.).
  • Ensure new entries are added to CHANGELOG.md, if applicable.

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@rakan-pro
rakan-pro requested a review from a team October 29, 2025 08:59
@github-actions github-actions Bot added component/api review-django-migrations This PR contains changes in Django migrations community Opened by the Community labels Oct 29, 2025
@github-actions

github-actions Bot commented Oct 29, 2025

Copy link
Copy Markdown
Contributor

Conflict Markers Resolved

All conflict markers have been successfully resolved in this pull request.

@github-actions

github-actions Bot commented Oct 29, 2025

Copy link
Copy Markdown
Contributor

✅ All necessary CHANGELOG.md files have been updated.

@github-actions

github-actions Bot commented Oct 29, 2025

Copy link
Copy Markdown
Contributor

🔒 Container Security Scan

Image: prowler-api:534d3ef
Last scan: 2025-11-07 12:15:34 UTC

📊 Vulnerability Summary

Severity Count
🔴 Critical 5
Total 5

4 package(s) affected

⚠️ Action Required

Critical severity vulnerabilities detected. These should be addressed before merging:

  • Review the detailed scan results
  • Update affected packages to patched versions
  • Consider using a different base image if updates are unavailable

📋 Resources:

josema-xyz
josema-xyz previously approved these changes Oct 29, 2025

@josema-xyz josema-xyz 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.

LGTM! 🚀

@josema-xyz josema-xyz added the backport-to-v5.13 Backport PR to the v5.13 branch label Oct 29, 2025
@vicferpoy vicferpoy removed the community Opened by the Community label Oct 29, 2025
@rakan-pro rakan-pro self-assigned this Nov 3, 2025
@rakan-pro
rakan-pro force-pushed the PROWLER-290-allow-multiple-provider-uid-when-they-are-deleted branch from af88f93 to 70105b2 Compare November 4, 2025 08:00
josema-xyz
josema-xyz previously approved these changes Nov 4, 2025

@josema-xyz josema-xyz 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.

Love the tests!

@rakan-pro rakan-pro added the no-merge Please, DO NOT MERGE this PR. label Nov 6, 2025
…-deleted entries

This change modifies the unique constraint on the Provider model to ensure that it only considers non-deleted entries. A new migration has been created to reflect this change in the database schema. Additionally, tests have been added to verify the behavior of soft deletion and the uniqueness of provider entries.
…-deleted entries

This change modifies the unique constraint on the Provider model to ensure that it only considers non-deleted entries. A new migration has been created to reflect this change in the database schema. Additionally, tests have been added to verify the behavior of soft deletion and the uniqueness of provider entries.
@rakan-pro
rakan-pro force-pushed the PROWLER-290-allow-multiple-provider-uid-when-they-are-deleted branch 3 times, most recently from dd4808d to ed811de Compare November 6, 2025 06:39
@codecov

codecov Bot commented Nov 6, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.26%. Comparing base (13e4866) to head (0a559cb).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #9054       +/-   ##
===========================================
+ Coverage   54.42%   94.26%   +39.84%     
===========================================
  Files          87      149       +62     
  Lines        2850    18695    +15845     
===========================================
+ Hits         1551    17623    +16072     
+ Misses       1299     1072      -227     
Flag Coverage Δ
api 94.26% <100.00%> (?)
prowler-py3.10-oraclecloud ?
prowler-py3.11-oraclecloud ?
prowler-py3.12-oraclecloud ?
prowler-py3.9-oraclecloud ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
prowler ∅ <ø> (∅)
api 94.26% <100.00%> (∅)
🚀 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.

@rakan-pro
rakan-pro force-pushed the PROWLER-290-allow-multiple-provider-uid-when-they-are-deleted branch from 925f861 to 9d78bf2 Compare November 6, 2025 08:24
@rakan-pro rakan-pro removed the no-merge Please, DO NOT MERGE this PR. label Nov 6, 2025
AdriiiPRodri
AdriiiPRodri previously approved these changes Nov 6, 2025
josema-xyz
josema-xyz previously approved these changes Nov 6, 2025
@rakan-pro
rakan-pro dismissed stale reviews from josema-xyz and AdriiiPRodri via 4c9a351 November 7, 2025 12:06
@AdriiiPRodri
AdriiiPRodri merged commit f0b1c4c into master Nov 7, 2025
31 checks passed
@AdriiiPRodri
AdriiiPRodri deleted the PROWLER-290-allow-multiple-provider-uid-when-they-are-deleted branch November 7, 2025 12:16
@prowler-bot prowler-bot added the was-backported The PR was successfully backported to the target branch label Nov 7, 2025
@prowler-bot

Copy link
Copy Markdown
Collaborator

💚 All backports created successfully

Status Branch Result
v5.13

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

rakan-pro added a commit that referenced this pull request Nov 17, 2025
#9054)

(cherry picked from commit f0b1c4c)

# Conflicts:
#	api/CHANGELOG.md
rakan-pro added a commit that referenced this pull request Nov 17, 2025
#9054)

(cherry picked from commit f0b1c4c)

# Conflicts:
#	api/CHANGELOG.md
rakan-pro added a commit that referenced this pull request Nov 17, 2025
#9054)

(cherry picked from commit f0b1c4c)

# Conflicts:
#	api/CHANGELOG.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-v5.13 Backport PR to the v5.13 branch component/api review-django-migrations This PR contains changes in Django migrations was-backported The PR was successfully backported to the target branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants