Re: [Django] #36775: Raise ImproperlyConfigured when Feed.link is missing instead of failing with AttributeError

2026-03-23 Thread Django
#36775: Raise ImproperlyConfigured when Feed.link is missing instead of failing
with AttributeError
-+-
 Reporter:  yureiblack   |Owner:
 Type:   |  yureiblack
  Cleanup/optimization   |   Status:  assigned
Component:  contrib.syndication  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  1|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Comment (by VinayDattarao):

 Hi, I’ve worked on this issue and implemented a fix.

 Previously, when `Feed.link` was missing, it resulted in an
 `AttributeError`. I’ve added an explicit check to ensure that `link` is
 present (and handled whether it is callable or not). Now, if it is missing
 or evaluates to an empty value, it raises `ImproperlyConfigured` with a
 clear error message instead.

 I’ve also verified that the change prevents the unintended
 `AttributeError` and provides a more appropriate and developer-friendly
 exception.

 Please let me know if you’d like me to add or adjust tests for this
 behavior before I open a PR.
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019d1c0eb399-8e944d85-24d7-47fb-8973-6fd89d385c1c-00%40eu-central-1.amazonses.com.


Re: [Django] #36775: Raise ImproperlyConfigured when Feed.link is missing instead of failing with AttributeError

2026-01-31 Thread Django
#36775: Raise ImproperlyConfigured when Feed.link is missing instead of failing
with AttributeError
-+-
 Reporter:  yureiblack   |Owner:
 Type:   |  yureiblack
  Cleanup/optimization   |   Status:  assigned
Component:  contrib.syndication  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  1|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by jaffar Khan):

 * cc: jaffar Khan (added)

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019c18203735-3e4fbeb3-bdce-43b9-ae0d-db0c31d11c3f-00%40eu-central-1.amazonses.com.


Re: [Django] #36775: Raise ImproperlyConfigured when Feed.link is missing instead of failing with AttributeError

2026-01-31 Thread Django
#36775: Raise ImproperlyConfigured when Feed.link is missing instead of failing
with AttributeError
-+-
 Reporter:  yureiblack   |Owner:
 Type:   |  yureiblack
  Cleanup/optimization   |   Status:  assigned
Component:  contrib.syndication  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  1|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Comment (by jaffar Khan):

 Can I work on this ticket since the current owner no longer seems to be
 active?
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019c181fb5b8-9b116f12-9939-41cd-a798-eebba9eb8001-00%40eu-central-1.amazonses.com.


Re: [Django] #36775: Raise ImproperlyConfigured when Feed.link is missing instead of failing with AttributeError

2025-12-04 Thread Django
#36775: Raise ImproperlyConfigured when Feed.link is missing instead of failing
with AttributeError
-+-
 Reporter:  yureiblack   |Owner:
 Type:   |  yureiblack
  Cleanup/optimization   |   Status:  assigned
Component:  contrib.syndication  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  1|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Jacob Walls):

 * needs_tests:  0 => 1
 * owner:  (none) => yureiblack
 * stage:  Unreviewed => Accepted
 * status:  new => assigned
 * type:  Bug => Cleanup/optimization


Old description:

> Currently, the `Feed.get_feed()` method retrieves the feed's `link`
> using:
>
> link = self._get_dynamic_attr("link", obj)
>
> If a Feed subclass does not define a `link` attribute, `link` becomes
> `None`.
> This results in an unhelpful exception when Django later calls:
>
> link = add_domain(current_site.domain, link, request.is_secure())
>
> Since `add_domain()` calls `url.startswith()`, a missing `link`
> causes:
>
> AttributeError: 'NoneType' object has no attribute 'startswith'
>
> This error does not clearly indicate the actual problem.
>
> According to Django documentation, every `Feed` class must define
> `link`. Therefore, it should raise a more appropriate and explicit
> exception.
>
> The attached PR adds the following check:
>
> if link is None:
> raise ImproperlyConfigured(
> "Feed class must define a 'link' attribute."
> )
>
> This results in a clearer error message and avoids unexpected crashes.
>
> PR: https://github.com/django/django/pull/20371

New description:

 Currently, the `Feed.get_feed()` method retrieves the feed's `link` using:
 {{{#!py
 link = self._get_dynamic_attr("link", obj)
 }}}
 If a Feed subclass does not define a `link` attribute, `link` becomes
 `None`.
 This results in an unhelpful exception when Django later calls:
 {{{#!py
 link = add_domain(current_site.domain, link, request.is_secure())
 }}}
 Since `add_domain()` calls `url.startswith()`, a missing `link`
 causes:
 {{{#!py
 AttributeError: 'NoneType' object has no attribute 'startswith'
 }}}
 This error does not clearly indicate the actual problem.

 According to Django documentation, every `Feed` class must define
 `link`. Therefore, it should raise a more appropriate and explicit
 exception.

 The attached PR adds the following check:
 {{{#!py
 if link is None:
 raise ImproperlyConfigured(
 "Feed class must define a 'link' attribute."
 )
 }}}
 This results in a clearer error message and avoids unexpected crashes.

 PR: https://github.com/django/django/pull/20371

--
Comment:

 Seems reasonable, thanks. (I think this is the "better error" described as
 "wouldn't kill us" in a very similar scenario in ticket:2218#comment:1.)

 Could you include a test?
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019aeafa5c57-024e8639-88de-4d13-b969-a93f9f35e045-00%40eu-central-1.amazonses.com.