Skip to content

🐛(backend) Fix unreachable exception handler for URLValidator#2172

Open
maboukerfa wants to merge 1 commit intosuitenumerique:mainfrom
maboukerfa:fix/urlvalidator-exception-handling
Open

🐛(backend) Fix unreachable exception handler for URLValidator#2172
maboukerfa wants to merge 1 commit intosuitenumerique:mainfrom
maboukerfa:fix/urlvalidator-exception-handling

Conversation

@maboukerfa
Copy link
Copy Markdown
Contributor

Purpose

The exception block was never being executed because URLValidator raises django.core.exceptions.ValidationError, not drf.exceptions.ValidationError, so the except block was dead code.

Proposal

Replace the drf.exceptions.ValidationError with Django 'ValidationError'

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 3, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 532ce1cb-87c4-4f7a-8bf0-081e00fc1e47

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ 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 and usage tips.

@lunika
Copy link
Copy Markdown
Member

lunika commented Apr 4, 2026

You are right, the exception is managed by the exception handler but not caught here.
The test should be failing with this modification; you have to update them.

The exception block was never being executed because
URLValidator raises django.core.exceptions.ValidationError,
not drf.exceptions.ValidationError.

Signed-off-by: Mohamed El Amine BOUKERFA <boukerfa.ma@gmail.com>
@maboukerfa maboukerfa force-pushed the fix/urlvalidator-exception-handling branch from e1e9918 to e6c0f30 Compare April 4, 2026 13:31
@maboukerfa
Copy link
Copy Markdown
Contributor Author

You are right, the exception is managed by the exception handler but not caught here. The test should be failing with this modification; you have to update them.

Thank you!
I updated the related test.
Screenshot 2026-04-04 at 15 38 19

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.

2 participants