@@ -477,3 +477,45 @@ def test_non_public_channel_token_returns_library_null(self):
477477 response = self .client .get (lookup_url )
478478 self .assertEqual (response .status_code , 200 )
479479 self .assertIsNone (response .data [0 ]["library" ])
480+
481+ def test_channel_version_with_none_version_returns_all_version_notes (self ):
482+ """
483+ When a ChannelVersion has version=None, _get_version_notes must not raise
484+ TypeError and must return all entries from channel.published_data.
485+ """
486+ self .channel .main_tree .published = True
487+ self .channel .main_tree .save ()
488+
489+ self .channel .published_data = {
490+ "1" : {"version_notes" : "v1 notes" },
491+ "3" : {"version_notes" : "v3 notes" },
492+ }
493+ # Set channel.version so Channel.on_update() auto-creates ChannelVersion(version=3).
494+ self .channel .version = 3
495+ self .channel .save ()
496+
497+ # Manually create a ChannelVersion with version=None to reproduce the Sentry bug.
498+ channel_version , _created = ChannelVersion .objects .get_or_create (
499+ channel = self .channel ,
500+ version = None ,
501+ defaults = {
502+ "kind_count" : [],
503+ "included_languages" : [],
504+ "resource_count" : 0 ,
505+ "size" : 0 ,
506+ },
507+ )
508+ version_token = channel_version .new_token ().token
509+
510+ lookup_url = reverse (
511+ "get_public_channel_lookup" ,
512+ kwargs = {"version" : "v1" , "identifier" : version_token },
513+ )
514+ response = self .client .get (lookup_url + "?channel_versions=true" )
515+
516+ self .assertEqual (response .status_code , 200 )
517+ self .assertEqual (len (response .data ), 1 )
518+ self .assertEqual (
519+ response .data [0 ]["version_notes" ],
520+ {1 : "v1 notes" , 3 : "v3 notes" },
521+ )
0 commit comments