Skip to content

Commit abfa074

Browse files
committed
add defensive check for none token for read events
1 parent 6176e2e commit abfa074

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

auditmiddleware/_api.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,16 @@ def register_resource(self, parent_type_uri, token):
365365
information to understand what happened. This allows for
366366
incremental improvement.
367367
"""
368+
# Defensive check for None token
369+
if token is None:
370+
self._log.warning("unknown resource: None (created on demand)")
371+
res_name = 'unknown'
372+
res_dict = {'api_name': 'unknown'}
373+
sub_res_spec, _ = self._build_res_spec(res_name,
374+
parent_type_uri,
375+
res_dict)
376+
return sub_res_spec
377+
368378
self._log.warning("unknown resource: %s (created on demand)",
369379
token)
370380
res_name = token.replace('_', '-')

0 commit comments

Comments
 (0)