internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: getmoto/moto

Issue:
Dependency 'decorator' not supported on Py2
Failing tests: https://github.com/spulec/moto/runs/2252652744?check_suite_focus=true

Error message when calling `boto3.client("cloudformation").validate_template()`:
` E       ImportError: cannot import name release`

#### Root cause:
`cfn-lint` requires `networkx` requires `decorator`. `decorator` has dropped support for Py2 as of 5.x

`cfn-lint` behaves as it should in Py2, and requires `networkx<=2.2`, which is the last version that supports Py2.7, but:

Networkx has an unbound dependency for `decorator`, always pulling in the latest version. 

I've raised an issue with networkx, just in case they want to support a 2 year old release: https://github.com/networkx/networkx/issues/4719

Will provide a PR to manually constrain the `decorator` dependency in the meantime


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -82,6 +82,7 @@ def get_version():
 _dep_aws_xray_sdk = "aws-xray-sdk!=0.96,>=0.93"
 _dep_idna = "idna<3,>=2.5"
 _dep_cfn_lint = "cfn-lint>=0.4.0"
+_dep_decorator = "decorator<=4.4.2; python_version<'3'"  # Transitive dependency - last version that supports py2.7
 _dep_sshpubkeys_py2 = "sshpubkeys==3.1.0; python_version<'3'"
 _dep_sshpubkeys_py3 = "sshpubkeys>=3.1.0; python_version>'3'"
 
@@ -94,6 +95,7 @@ def get_version():
     _dep_aws_xray_sdk,
     _dep_idna,
     _dep_cfn_lint,
+    _dep_decorator,
     _dep_sshpubkeys_py2,
     _dep_sshpubkeys_py3,
 ]
@@ -106,7 +108,7 @@ def get_version():
     "apigateway": [_dep_python_jose, _dep_python_jose_ecdsa_pin],
     "awslambda": [_dep_docker],
     "batch": [_dep_docker],
-    "cloudformation": [_dep_docker, _dep_PyYAML, _dep_cfn_lint],
+    "cloudformation": [_dep_docker, _dep_PyYAML, _dep_cfn_lint, _dep_decorator],
     "cognitoidp": [_dep_python_jose, _dep_python_jose_ecdsa_pin],
     "dynamodb2": [_dep_docker],
     "dynamodbstreams": [_dep_docker],
@@ -116,7 +118,7 @@ def get_version():
     "ses": [_dep_docker],
     "sns": [_dep_docker],
     "sqs": [_dep_docker],
-    "ssm": [_dep_docker, _dep_PyYAML, _dep_cfn_lint],
+    "ssm": [_dep_docker, _dep_PyYAML, _dep_cfn_lint, _dep_decorator],
     "xray": [_dep_aws_xray_sdk],
 }
 extras_require = {


Test patch:
Repository: getmoto/moto

Issue:
IoT list_principal_things should be return list of thingnames.
## Summary

IoT `list_principal_things` should be return list of thingnames.

But, moto will returns list of certification arn



## Reproduction procedure

### Use boto3



```
>>> import boto3
>>> client = boto3.client('iot')
>>> my_certification_arn = 'arn:aws:iot:ap-northeast-1:123456789012:cert/xxxxx'
>>> res = client.list_principal_things(principal=my_certification_arn)
>>> print(res['things'])
['my-thing-name']
```



### Use moto

```
>>> import boto3
>>> import moto
>>> moto.mock_iot().start()
>>> client = boto3.client('iot')
>>> client.create_thing(thingName='my-thing-name')
>>> res = client.create_keys_and_certificate()
>>> my_certification_arn = res['certificateArn']
>>> client.attach_thing_principal(thingName='my-thing-name',principal=my_certification_arn)
>>> res = client.list_principal_things(principal=my_certification_arn)
>>> print(res['things'])
['arn:aws:iot:ap-northeast-1:1:cert/78a910bb69eae8d99bdd5e104a136a37576ab202871194f35a902e9033e6aab9']
```



## moto and boto version

```
boto3              1.17.53
botocore         1.20.53
moto                2.0.5
```




Discussion:

Resolving patch:
diff --git a/moto/iot/models.py b/moto/iot/models.py
--- a/moto/iot/models.py
+++ b/moto/iot/models.py
@@ -925,7 +925,7 @@ def detach_thing_principal(self, thing_name, principal_arn):
 
     def list_principal_things(self, principal_arn):
         thing_names = [
-            k[0] for k, v in self.principal_things.items() if k[0] == principal_arn
+            k[1] for k, v in self.principal_things.items() if k[0] == principal_arn
         ]
         return thing_names
 


Test patch:
diff --git a/tests/test_iot/test_iot.py b/tests/test_iot/test_iot.py
--- a/tests/test_iot/test_iot.py
+++ b/tests/test_iot/test_iot.py
@@ -847,8 +847,7 @@ def test_principal_thing():
 
     res = client.list_principal_things(principal=cert_arn)
     res.should.have.key("things").which.should.have.length_of(1)
-    for thing in res["things"]:
-        thing.should_not.be.none
+    res["things"][0].should.equal(thing_name)
     res = client.list_thing_principals(thingName=thing_name)
     res.should.have.key("principals").which.should.have.length_of(1)
     for principal in res["principals"]:
Repository: getmoto/moto

Issue:
MarkupSafe vs Jinja dependency issues
 I'm trying to run tests as part of #3866 .
 
 I'm not able to `make init`. I've had about 4 different errors.
 
 I'm trying to do it in Docker, hoping that doing it in a clean slate makes this reproducable. 

# Steps to reproduce

Add `/tests/Dockerfile`:

```
FROM python:3.7-buster

ADD . /moto/
ENV PYTHONUNBUFFERED 1
WORKDIR /moto/
RUN make init
RUN make test
```

From the top of the repo, run `docker build -f tests/Dockerfile .`

# Expected behavior

Build completes without error. That is, `make init` and `make test` ran without error, inside a clean Ubuntu Buster image.

# Actual behavior

```
Installed /usr/local/lib/python3.7/site-packages/boto3-1.17.57-py3.7.egg
error: MarkupSafe 1.1.1 is installed but MarkupSafe>=2.0.0rc2 is required by {'Jinja2'}
make: *** [Makefile:13: init] Error 1
The command '/bin/sh -c make init' returned a non-zero code: 2
```

# Solution

I'm about to push a PR. The dependency for Markup needs to change from < to != .


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -40,7 +40,7 @@ def get_version():
     "pytz",
     "python-dateutil<3.0.0,>=2.1",
     "responses>=0.9.0",
-    "MarkupSafe<2.0",  # This is a Jinja2 dependency, 2.0.0a1 currently seems broken
+    "MarkupSafe!=2.0.0a1",  # This is a Jinja2 dependency, 2.0.0a1 currently seems broken
 ]
 
 #


Test patch:
Repository: getmoto/moto

Issue:
Add support for Jinja version 3.0.0
Flask has released a new version that requires Jinja>=3.0.0. There are a lot of improvements in this version upgrade. Currently, this library is requiring that Jinja < 3.0.0. 


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -99,7 +99,7 @@ def get_version():
     _dep_sshpubkeys_py2,
     _dep_sshpubkeys_py3,
 ]
-all_server_deps = all_extra_deps + ["flask", "flask-cors"]
+all_server_deps = all_extra_deps + ["flask<2.0.0", "flask-cors"]
 
 # TODO: do we want to add ALL services here?
 # i.e. even those without extra dependencies.


Test patch:
Repository: getmoto/moto

Issue:
AWS Config S3 ACLs missing owner
It looks like AWS Config for S3 has a slightly different behavior from when I initially wrote the capability a while back. AWS Config is now including the default account owner ACL in the grantees now.

The following lines need to be removed:
https://github.com/spulec/moto/blob/master/moto/s3/models.py#L439-L441

I will make a PR soon to fix.


Discussion:

Resolving patch:
diff --git a/moto/s3/models.py b/moto/s3/models.py
--- a/moto/s3/models.py
+++ b/moto/s3/models.py
@@ -436,10 +436,6 @@ def to_config_dict(self):
             )
             for permission in permissions:
                 for grantee in grant.grantees:
-                    # Config does not add the owner if its permissions are FULL_CONTROL:
-                    if permission == "FULL_CONTROL" and grantee.id == OWNER:
-                        continue
-
                     if grantee.uri:
                         grant_list.append(
                             {


Test patch:
diff --git a/tests/test_s3/test_s3.py b/tests/test_s3/test_s3.py
--- a/tests/test_s3/test_s3.py
+++ b/tests/test_s3/test_s3.py
@@ -4648,7 +4648,15 @@ def test_s3_acl_to_config_dict():
 
     # Get the config dict with nothing other than the owner details:
     acls = s3_config_query.backends["global"].buckets["logbucket"].acl.to_config_dict()
-    assert acls == {"grantSet": None, "owner": {"displayName": None, "id": OWNER}}
+    owner_acl = {
+        "grantee": {"id": OWNER, "displayName": None},
+        "permission": "FullControl",
+    }
+    assert acls == {
+        "grantSet": None,
+        "owner": {"displayName": None, "id": OWNER},
+        "grantList": [owner_acl],
+    }
 
     # Add some Log Bucket ACLs:
     log_acls = FakeAcl(
@@ -4672,6 +4680,13 @@ def test_s3_acl_to_config_dict():
         "grantList": [
             {"grantee": "LogDelivery", "permission": "Write"},
             {"grantee": "LogDelivery", "permission": "ReadAcp"},
+            {
+                "grantee": {
+                    "displayName": None,
+                    "id": "75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a",
+                },
+                "permission": "FullControl",
+            },
         ],
         "owner": {"displayName": None, "id": OWNER},
     }
@@ -4791,6 +4806,15 @@ def test_s3_config_dict():
         json.loads(bucket1_result["supplementaryConfiguration"]["AccessControlList"])
     ) == {
         "grantSet": None,
+        "grantList": [
+            {
+                "grantee": {
+                    "displayName": None,
+                    "id": "75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a",
+                },
+                "permission": "FullControl",
+            },
+        ],
         "owner": {
             "displayName": None,
             "id": "75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a",
Repository: getmoto/moto

Issue:
importlib_resources is not mentioned in requirements
The package `importlib-resources` should be added to the appropriate place of your requirements setup, at least for Python < 3.7, as you use it here:

https://github.com/spulec/moto/blob/9bc6bded6e6472f04a45f0bc429acc926c2cdc08/moto/dynamodb2/parsing/reserved_keywords.py#L21-L24


Discussion:
Thanks for raising this @bnavigator!

Resolving patch:
diff --git a/moto/dynamodb2/parsing/reserved_keywords.py b/moto/dynamodb2/parsing/reserved_keywords.py
--- a/moto/dynamodb2/parsing/reserved_keywords.py
+++ b/moto/dynamodb2/parsing/reserved_keywords.py
@@ -1,3 +1,7 @@
+from moto.utilities.utils import load_resource
+from pkg_resources import resource_filename
+
+
 class ReservedKeywords(list):
     """
     DynamoDB has an extensive list of keywords. Keywords are considered when validating the expression Tree.
@@ -18,12 +22,7 @@ def _get_reserved_keywords(cls):
         """
         Get a list of reserved keywords of DynamoDB
         """
-        try:
-            import importlib.resources as pkg_resources
-        except ImportError:
-            import importlib_resources as pkg_resources
-
-        reserved_keywords = pkg_resources.read_text(
-            "moto.dynamodb2.parsing", "reserved_keywords.txt"
+        reserved_keywords = load_resource(
+            resource_filename(__name__, "reserved_keywords.txt"), as_json=False
         )
         return reserved_keywords.split()
diff --git a/moto/utilities/utils.py b/moto/utilities/utils.py
--- a/moto/utilities/utils.py
+++ b/moto/utilities/utils.py
@@ -15,7 +15,7 @@ def random_string(length=None):
     return random_str
 
 
-def load_resource(filename):
+def load_resource(filename, as_json=True):
     """
     Open a file, and return the contents as JSON.
     Usage:
@@ -23,4 +23,4 @@ def load_resource(filename):
     load_resource(resource_filename(__name__, "resources/file.json"))
     """
     with open(filename, "r", encoding="utf-8") as f:
-        return json.load(f)
+        return json.load(f) if as_json else f.read()


Test patch:
Repository: getmoto/moto

Issue:
Wrong error message when pushing logs to non-existent stream in existing group
# MWE

```
import boto3
from moto import mock_logs
from time import time

mock_logs().start()

group_name = 'my-group-2'
stream_name = 'my-stream'

client = boto3.client('logs')

client.create_log_group(logGroupName=group_name)

# I forgot to do this in my real code
# so the error from moto/boto should tell me this is the part I forgot
#client.create_log_stream(
#    logGroupName=group_name,
#    logStreamName=stream_name
#)

client.put_log_events(
    logGroupName=group_name,
    logStreamName=stream_name,
    logEvents=[
        {
            'timestamp': int(time()),
            'message': 'test'
        },
    ]
)
```

# Expected behavior

If you run the above script without `moto`, you get:

> botocore.errorfactory.ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the PutLogEvents operation: The specified log **stream** does not exist.

# actual behavior

If you run the above script with `moto`, you get:

> botocore.errorfactory.ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the PutLogEvents operation: The specified log **group** does not exist

The group *does* exist. The problem with the `put_log_events` call is that the *stream* does not exist. This difference in error message makes it hard to figure out why the whole script does not pass.


Discussion:
Thanks @mdavis-xyz - marking it as an enhancement

Resolving patch:
diff --git a/moto/logs/models.py b/moto/logs/models.py
--- a/moto/logs/models.py
+++ b/moto/logs/models.py
@@ -333,7 +333,7 @@ def put_log_events(
         self, log_group_name, log_stream_name, log_events, sequence_token
     ):
         if log_stream_name not in self.streams:
-            raise ResourceNotFoundException()
+            raise ResourceNotFoundException("The specified log stream does not exist.")
         stream = self.streams[log_stream_name]
         return stream.put_log_events(
             log_group_name, log_stream_name, log_events, sequence_token


Test patch:
diff --git a/tests/test_logs/test_logs.py b/tests/test_logs/test_logs.py
--- a/tests/test_logs/test_logs.py
+++ b/tests/test_logs/test_logs.py
@@ -46,12 +46,15 @@ def test_exceptions():
         logEvents=[{"timestamp": 0, "message": "line"}],
     )
 
-    with pytest.raises(ClientError):
+    with pytest.raises(ClientError) as ex:
         conn.put_log_events(
             logGroupName=log_group_name,
             logStreamName="invalid-stream",
             logEvents=[{"timestamp": 0, "message": "line"}],
         )
+    error = ex.value.response["Error"]
+    error["Code"].should.equal("ResourceNotFoundException")
+    error["Message"].should.equal("The specified log stream does not exist.")
 
 
 @mock_logs
Repository: getmoto/moto

Issue:
Bug when deregistering job definition by name/ revision
When deregistering a batch job definition with `deregister_job_definition()` the required parameter is as follows:
```
    jobDefinition (string) --

    [REQUIRED]

    The name and revision (name:revision ) or full Amazon Resource Name (ARN) of the job definition to deregister.
```
Currently when trying to deregister with `name:revision` it is not working as the `name:revision` string is split up and `revision` ends up type `str`. Due to this, when it is compared to the definition to be deleted it does not match as `revision` is stored in the `jobDefinition` object as an `int`. This isn't caught in the current testing as the test requests deletion by ARN.

I have made a fix to correct this and will attach the pull request.


Discussion:

Resolving patch:
diff --git a/moto/batch/models.py b/moto/batch/models.py
--- a/moto/batch/models.py
+++ b/moto/batch/models.py
@@ -718,7 +718,7 @@ def get_job_definition_by_name(self, name):
 
     def get_job_definition_by_name_revision(self, name, revision):
         for job_def in self._job_definitions.values():
-            if job_def.name == name and job_def.revision == revision:
+            if job_def.name == name and job_def.revision == int(revision):
                 return job_def
         return None
 


Test patch:
diff --git a/tests/test_batch/test_batch_task_definition.py b/tests/test_batch/test_batch_task_definition.py
--- a/tests/test_batch/test_batch_task_definition.py
+++ b/tests/test_batch/test_batch_task_definition.py
@@ -97,6 +97,24 @@ def test_delete_task_definition():
     len(resp["jobDefinitions"]).should.equal(0)
 
 
+@mock_ec2
+@mock_ecs
+@mock_iam
+@mock_batch
+def test_delete_task_definition_by_name():
+    ec2_client, iam_client, ecs_client, logs_client, batch_client = _get_clients()
+    _setup(ec2_client, iam_client)
+
+    resp = register_job_def(batch_client)
+
+    batch_client.deregister_job_definition(
+        jobDefinition=f"{resp['jobDefinitionName']}:{resp['revision']}"
+    )
+
+    resp = batch_client.describe_job_definitions()
+    len(resp["jobDefinitions"]).should.equal(0)
+
+
 @mock_ec2
 @mock_ecs
 @mock_iam
Repository: getmoto/moto

Issue:
Tagging SSM parameter when overwriting should throw validation error
# MWE

```
import boto3
from moto import mock_ssm

mock_ssm().start()

boto3.client('ssm').put_parameter(
    Name='test-param',
    Description=f'Delete after 14/9/21',
    Value='abc',
    Type='String',
    Overwrite=True,
    Tags=[
        {
            'Key': 'mytag',
            'Value': 'myval'
        }
    ],
)
```

## Behavior with moto

The script runs without throwing an exception


## behavior without moto

```
Traceback (most recent call last):
  File "param.py", line 4, in <module>
    boto3.client('ssm').put_parameter(
  File "/home/ec2-user/.pyenv/versions/3.8.11/lib/python3.8/site-packages/botocore/client.py", line 386, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/home/ec2-user/.pyenv/versions/3.8.11/lib/python3.8/site-packages/botocore/client.py", line 705, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the PutParameter operation: Invalid request: tags and overwrite can't be used together. To create a parameter with tags, please remove overwrite flag. To update tags for an existing parameter, please use AddTagsToResource or RemoveTagsFromResource.
```


Discussion:
Thanks for the MWE @mdavis-xyz - will mark it as an enhancement to implement this validation.

Resolving patch:
diff --git a/moto/ssm/models.py b/moto/ssm/models.py
--- a/moto/ssm/models.py
+++ b/moto/ssm/models.py
@@ -1547,6 +1547,12 @@ def put_parameter(
                 "1 validation error detected: Value '' at 'value' failed to satisfy"
                 " constraint: Member must have length greater than or equal to 1."
             )
+        if overwrite and tags:
+            raise ValidationException(
+                "Invalid request: tags and overwrite can't be used together. To create a "
+                "parameter with tags, please remove overwrite flag. To update tags for an "
+                "existing parameter, please use AddTagsToResource or RemoveTagsFromResource."
+            )
         if name.lower().lstrip("/").startswith("aws") or name.lower().lstrip(
             "/"
         ).startswith("ssm"):


Test patch:
diff --git a/tests/test_ssm/test_ssm_boto3.py b/tests/test_ssm/test_ssm_boto3.py
--- a/tests/test_ssm/test_ssm_boto3.py
+++ b/tests/test_ssm/test_ssm_boto3.py
@@ -279,6 +279,19 @@ def test_put_parameter(name):
         "arn:aws:ssm:us-east-1:{}:parameter/{}".format(ACCOUNT_ID, name)
     )
     new_data_type = "aws:ec2:image"
+
+    with pytest.raises(ClientError) as ex:
+        response = client.put_parameter(
+            Name=name,
+            Description="desc 3",
+            Value="value 3",
+            Type="String",
+            Overwrite=True,
+            Tags=[{"Key": "foo", "Value": "bar"}],
+            DataType=new_data_type,
+        )
+    assert ex.value.response["Error"]["Code"] == "ValidationException"
+
     response = client.put_parameter(
         Name=name,
         Description="desc 3",
Repository: getmoto/moto

Issue:
Add support for `ELBSecurityPolicy-FS-1-2-Res-2020-10` ALB SSL policy.
Add support for `ELBSecurityPolicy-FS-1-2-Res-2020-10` ALB SSL policy. [List of supported SSL Listener Policies](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/create-https-listener.html).



After [this line](https://github.com/spulec/moto/blob/e9a4100324f8dd7e2260a34711dbff0e32ae40bb/moto/elbv2/responses.py#L127), the following snippet has to be added:
```python
 {
            "SslProtocols": [
                "TLSv1.2"
            ],
            "Ciphers": [
                {
                    "Name": "ECDHE-ECDSA-AES128-GCM-SHA256",
                    "Priority": 1
                },
                {
                    "Name": "ECDHE-RSA-AES128-GCM-SHA256",
                    "Priority": 2
                },
                {
                    "Name": "ECDHE-ECDSA-AES256-GCM-SHA384",
                    "Priority": 3
                },
                {
                    "Name": "ECDHE-RSA-AES256-GCM-SHA384",
                    "Priority": 4
                }
            ],
            "Name": "ELBSecurityPolicy-FS-1-2-Res-2020-10"
}
```


Discussion:
Thanks for raising this @shreeshacoder!
I can make a PR for this addition. Feel free to assign the issue to me. 

Resolving patch:
diff --git a/moto/elbv2/responses.py b/moto/elbv2/responses.py
--- a/moto/elbv2/responses.py
+++ b/moto/elbv2/responses.py
@@ -125,6 +125,16 @@
             {"name": "DES-CBC3-SHA", "priority": 19},
         ],
     },
+    {
+        "name": "ELBSecurityPolicy-FS-1-2-Res-2020-10",
+        "ssl_protocols": ["TLSv1.2"],
+        "ciphers": [
+            {"name": "ECDHE-ECDSA-AES128-GCM-SHA256", "priority": 1},
+            {"name": "ECDHE-RSA-AES128-GCM-SHA256", "priority": 2},
+            {"name": "ECDHE-ECDSA-AES256-GCM-SHA384", "priority": 3},
+            {"name": "ECDHE-RSA-AES256-GCM-SHA384", "priority": 4},
+        ],
+    },
 ]
 
 


Test patch:
diff --git a/tests/test_elbv2/test_elbv2.py b/tests/test_elbv2/test_elbv2.py
--- a/tests/test_elbv2/test_elbv2.py
+++ b/tests/test_elbv2/test_elbv2.py
@@ -1311,10 +1311,19 @@ def test_describe_ssl_policies():
     client = boto3.client("elbv2", region_name="eu-central-1")
 
     resp = client.describe_ssl_policies()
-    len(resp["SslPolicies"]).should.equal(5)
+    len(resp["SslPolicies"]).should.equal(6)
 
     resp = client.describe_ssl_policies(
-        Names=["ELBSecurityPolicy-TLS-1-2-2017-01", "ELBSecurityPolicy-2016-08"]
+        Names=["ELBSecurityPolicy-TLS-1-2-2017-01", "ELBSecurityPolicy-2016-08",]
+    )
+    len(resp["SslPolicies"]).should.equal(2)
+
+    resp = client.describe_ssl_policies(
+        Names=[
+            "ELBSecurityPolicy-TLS-1-2-2017-01",
+            "ELBSecurityPolicy-2016-08",
+            "ELBSecurityPolicy-2016-08",
+        ]
     )
     len(resp["SslPolicies"]).should.equal(2)