# Buggy code
def process(self, network_addrs):
    client = local_session(self.manager.session_factory).client("ec2")
    force = self.data.get("force")
    assoc_addrs = [addr for addr in network_addrs if "AssociationId" in addr]
    unassoc_addrs = [addr for addr in network_addrs if "AssociationId" not in addr]

    if len(assoc_addrs) and not force:
        self.log.warning(
            "Filtered %d attached eips of %d eips. Use 'force: true' to release them.",
            len(assoc_addrs),
            len(network_addrs),
        )
    elif len(assoc_addrs) and force:
        unassoc_addrs = itertools.chain(
            unassoc_addrs, self.process_attached(client, assoc_addrs)
        )

    for r in unassoc_addrs:
        try:
            client.release_address(AllocationId=r["AllocationId"])
        except BotoClientError as e:
            # If its already been released, ignore, else raise.
            if e.response["Error"]["Code"] == "InvalidAllocationID.NotFound":
                raise


# Traceback (AttributeError)
2019-01-18 02:34:48,434: custodian.policy:INFO policy: support-tag-compliance-import-findings resource:aws.support-case region:us-east-1 count:2 time:0.47
2019-01-18 02:34:48,440: custodian.output:ERROR Error while executing policy
Traceback (most recent call last):
File "/home/ec2-user/environment/cloud-custodian/.tox/py37/lib/python3.7/site-packages/c7n/policy.py", line 264, in run
results = a.process(resources)
File "/home/ec2-user/environment/cloud-custodian/.tox/py37/lib/python3.7/site-packages/c7n/actions/securityhub.py", line 202, in process
resource_set, finding_id, created_at, updated_at)
File "/home/ec2-user/environment/cloud-custodian/.tox/py37/lib/python3.7/site-packages/c7n/actions/securityhub.py", line 312, in get_finding
finding_resources.append(self.format_resource(r))
File "/home/ec2-user/environment/cloud-custodian/.tox/py37/lib/python3.7/site-packages/c7n/actions/securityhub.py", line 353, in format_resource
'Id': self.manager.get_arns([r])[0],
File "/home/ec2-user/environment/cloud-custodian/.tox/py37/lib/python3.7/site-packages/c7n/query.py", line 500, in get_arns
arns.append(self.generate_arn(_id))
File "/home/ec2-user/environment/cloud-custodian/.tox/py37/lib/python3.7/site-packages/c7n/query.py", line 513, in generate_arn
resource_type=self.get_model().type,
AttributeError: type object 'resource_type' has no attribute 'type'

# Fixed code
def process(self, network_addrs):
    client = local_session(self.manager.session_factory).client("ec2")
    force = self.data.get("force")
    assoc_addrs = [addr for addr in network_addrs if "AssociationId" in addr]
    unassoc_addrs = [addr for addr in network_addrs if "AssociationId" not in addr]

    if len(assoc_addrs) and not force:
        self.log.warning(
            "Filtered %d attached eips of %d eips. Use 'force: true' to release them.",
            len(assoc_addrs),
            len(network_addrs),
        )
    elif len(assoc_addrs) and force:
        unassoc_addrs = itertools.chain(
            unassoc_addrs, self.process_attached(client, assoc_addrs)
        )

    for r in unassoc_addrs:
        try:
            client.release_address(AllocationId=r["AllocationId"])
        except ClientError as e:
            # If its already been released, ignore, else raise.
            if e.response["Error"]["Code"] == "InvalidAllocationID.NotFound":
                raise