usdigitalresponse / cpf-reporter

CPF Reporter application maintained by the USDR Grants program.
Apache License 2.0
0 stars 4 forks source link

[Bug] - tresury report does not generate if projects in all three project-types do not exist #489

Open as1729 opened 1 month ago

as1729 commented 1 month ago

Current State

If the organization only has either 1A, 1B, or 1C or missing any of these project types, then the treasury report raises the following error.

[ERROR] AttributeError: 'NoneType' object has no attribute '__name__'
Traceback (most recent call last):
  File "/opt/python/lib/python3.12/site-packages/datadog_lambda/wrapper.py", line 232, in __call__
    self.response = self.func(event, context, **kwargs)
  File "/var/task/src/lib/logging.py", line 54, in inner
    def inner(*args, **kwargs):
  File "/opt/python/lib/python3.12/site-packages/ddtrace/contrib/aws_lambda/patch.py", line 120, in __call__
    self.response = self.func(*args, **kwargs)
  File "/var/task/src/lib/logging.py", line 56, in inner
    return func(*args, **kwargs)
  File "/var/task/src/functions/generate_treasury_report.py", line 79, in handle
    logger.exception("Missing event or context")
  File "/var/task/structlog/_native.py", line 45, in exception
    return self.error(event, *args, **kw)
  File "/var/task/structlog/_native.py", line 134, in meth
    return self._proxy_to_logger(name, event, **kw)
  File "/var/task/structlog/_base.py", line 214, in _proxy_to_logger
    args, kw = self._process_event(method_name, event, event_kw)
  File "/var/task/structlog/_base.py", line 165, in _process_event
    event_dict = proc(self._logger, method_name, event_dict)
  File "/var/task/structlog/processors.py", line 412, in __call__
    event_dict["exception"] = self.format_exception(
  File "/var/task/structlog/tracebacks.py", line 415, in __call__
    trace = extract(
  File "/var/task/structlog/tracebacks.py", line 231, in extract
    exc_type=safe_str(exc_type.__name__),

Expected State

The treasury report generation should not raise any errors if the organization only has one type of project. It should merely put a log indicating that the organization does not have any uploads with the specific project type.