@@ -95,17 +95,22 @@ export class K8sDomain extends Domain {
9595 let namespace = selector . namespace ;
9696 let name = selector . name ;
9797 let events = '' ;
98- if ( isEvent ( model ) ) {
98+ if ( isEvent ( model ) && selector . fields ) {
9999 // Special case for events, generate URL of involved object with '/events' modifier.
100+ // Only apply this if fields are present (indicating an event about a specific object).
100101 const eventClass = this . modelClass ( model ) ;
101102 const about = eventAboutField ( model ) ;
102- const [ group , version ] = parseAPIVersion ( selector . fields [ `${ about } .apiVersion` ] ) ;
103+ const apiVersion = selector . fields [ `${ about } .apiVersion` ] ;
103104 const kind = selector . fields [ `${ about } .kind` ] ;
104- model = findGVK ( group , version , kind ) ;
105- if ( ! model ) throw this . badQuery ( query , `no resource matching ${ eventClass } .${ about } ` ) ;
106- namespace = selector . fields [ `${ about } .namespace` ] || '' ;
107- name = selector . fields [ `${ about } .name` ] || '' ;
108- events = '/events' ;
105+ // Only treat as an involved object event if the required fields are present
106+ if ( apiVersion && kind ) {
107+ const [ group , version ] = parseAPIVersion ( apiVersion ) ;
108+ model = findGVK ( group , version , kind ) ;
109+ if ( ! model ) throw this . badQuery ( query , `no resource matching ${ eventClass } .${ about } ` ) ;
110+ namespace = selector . fields [ `${ about } .namespace` ] || '' ;
111+ name = selector . fields [ `${ about } .name` ] || '' ;
112+ events = '/events' ;
113+ }
109114 }
110115 // Prepare parts of the URL
111116 const nsPath = namespace ? `ns/${ namespace } ` : 'all-namespaces' ;
0 commit comments