# Buggy code
def process(self, resources, event=None):
    for r in resources:
        region = self.manager.config.region
        trail_arn = Arn.parse(r["TrailARN"])

        if (
            r.get("IsOrganizationTrail")
            and self.manager.config.account_id != trail_arn.account_id
        ):
            continue
        if r.get("HomeRegion") and r["HomeRegion"] != region:
            region = trail_arn.region
        if self.annotation_key in r:
            continue
        client = local_session(self.manager.session_factory).client(
            "cloudtrail", region_name=region
        )
        status = client.get_trail_status(Name=r["Name"])
        status.pop("ResponseMetadata")
        r[self.annotation_key] = status

    return super(Status, self).process(resources)


# Traceback (KeyError)
2020-05-05 09:03:16,332: custodian.commands:ERROR Error while executing policy awslogs-cloudtrail, continuing
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/c7n/commands.py", line 281, in run
policy()
File "/usr/local/lib/python3.7/site-packages/c7n/policy.py", line 1062, in __call__
resources = mode.run()
File "/usr/local/lib/python3.7/site-packages/c7n/policy.py", line 291, in run
resources = self.policy.resource_manager.resources()
File "/usr/local/lib/python3.7/site-packages/c7n/query.py", line 466, in resources
resources = self.filter_resources(resources)
File "/usr/local/lib/python3.7/site-packages/c7n/manager.py", line 109, in filter_resources
resources = f.process(resources, event)
File "/usr/local/lib/python3.7/site-packages/c7n/resources/cloudtrail.py", line 122, in process
return super(Status, self).process(resources)
File "/usr/local/lib/python3.7/site-packages/c7n/filters/core.py", line 499, in process
return super(ValueFilter, self).process(resources, event)
File "/usr/local/lib/python3.7/site-packages/c7n/filters/core.py", line 197, in process
return list(filter(self, resources))
File "/usr/local/lib/python3.7/site-packages/c7n/resources/cloudtrail.py", line 125, in __call__
return self.match(r['c7n:TrailStatus'])
KeyError: 'c7n:TrailStatus'

# Fixed code
def process(self, resources, event=None):
    non_account_trails = set()

    for r in resources:
        region = self.manager.config.region
        trail_arn = Arn.parse(r["TrailARN"])

        if (
            r.get("IsOrganizationTrail")
            and self.manager.config.account_id != trail_arn.account_id
        ):
            non_account_trails.add(r["TrailARN"])
            continue
        if r.get("HomeRegion") and r["HomeRegion"] != region:
            region = trail_arn.region
        if self.annotation_key in r:
            continue
        client = local_session(self.manager.session_factory).client(
            "cloudtrail", region_name=region
        )
        status = client.get_trail_status(Name=r["Name"])
        status.pop("ResponseMetadata")
        r[self.annotation_key] = status

    if non_account_trails:
        self.log.warning(
            "found %d org cloud trail from different account that cant be processed",
            len(non_account_trails),
        )
    return super(Status, self).process(
        [r for r in resources if r["TrailARN"] not in non_account_trails]
    )