internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: craiga/will-of-the-prophets

Issue:
Figure out how timezones should work on roll page
Times are in UTC. Ben and Adam will be using this from the US. Can we auto-detect the user's timezone? Is this something Django can do for us?


Discussion:

Resolving patch:
diff --git a/will_of_the_prophets/settings/__init__.py b/will_of_the_prophets/settings/__init__.py
--- a/will_of_the_prophets/settings/__init__.py
+++ b/will_of_the_prophets/settings/__init__.py
@@ -43,6 +43,7 @@
     'django.contrib.staticfiles',
     'sass_processor',
     'widget_tweaks',
+    'tz_detect',
     'bootstrap',
     'will_of_the_prophets',
 ]
@@ -144,5 +145,14 @@
 SASS_OUTPUT_STYLE = 'compressed'
 
 
+# django-tz-detect
+# https://github.com/adamcharnock/django-tz-detect
+MIDDLEWARE += [
+    'tz_detect.middleware.TimezoneMiddleware',
+]
+
+TZ_DETECT_COUNTRIES = ('US', 'CN', 'IN', 'JP', 'BR', 'RU', 'DE', 'FR', 'GB')
+
+
 # Configure Django App for Heroku.
 django_heroku.settings(locals())
diff --git a/will_of_the_prophets/urls.py b/will_of_the_prophets/urls.py
--- a/will_of_the_prophets/urls.py
+++ b/will_of_the_prophets/urls.py
@@ -23,5 +23,6 @@
     path('admin/', admin.site.urls),
     path('accounts/', include('django.contrib.auth.urls')),
     path('roll/', views.RollView.as_view(), name='roll'),
+    path('tz_detect/', include('tz_detect.urls')),
     path('', views.public_board, name='public_board'),
 ]


Test patch:
Repository: craiga/will-of-the-prophets

Issue:
Mobile-friendly layout
Sidebar should drop below the board once "mornhammered" becomes too wide for the window.


Discussion:

Resolving patch:
diff --git a/will_of_the_prophets/views.py b/will_of_the_prophets/views.py
--- a/will_of_the_prophets/views.py
+++ b/will_of_the_prophets/views.py
@@ -35,4 +35,4 @@ def get_context_data(self, **kwargs):
             special_square_types=models.SpecialSquareType.objects.all())
 
     def get_success_url(self):
-        return reverse('roll')
+        return reverse('roll') + "#chula"


Test patch:
Repository: AnalogJ/lexicon

Issue:
SPF support could be confusing
I note that the SPF RR type was discontinued in RFC 7208 (see https://tools.ietf.org/html/rfc7208#section-3.1). I tried searching for my own SPF records with the SPF type, but of course they were not found (they do show up as TXT records, which they are). This could lead to confusion as to whether the command should return SPF records (which are implemented as standard TXT records) or records of the SPF RR type (which has been discontinued).

For clarity, I would suggest that lexicon drop the SPF RR type. Alternately, you could allow listing the SPF RR type (possibly with a printed message for the user that notes that SPF records implemented as TXT records will not be returned), and disallow creation of SPF RRs (since current RFC specifies that  it must be implemented by TXT record only).



Discussion:
I concur. We will likely be dropping the SPF type in DNSimple at some point in favor of just the TXT record type for SPF.

Yeah, dropping SPF looks like a good idea, I didn't realize it was deprecated. I've never used one myself, and initially just added it because it was supported by some of the providers. 


Resolving patch:
diff --git a/lexicon/__main__.py b/lexicon/__main__.py
--- a/lexicon/__main__.py
+++ b/lexicon/__main__.py
@@ -12,7 +12,7 @@ def BaseProviderParser():
     parser = argparse.ArgumentParser(add_help=False)
     parser.add_argument("action", help="specify the action to take", default='list', choices=['create', 'list', 'update', 'delete'])
     parser.add_argument("domain", help="specify the domain, supports subdomains as well")
-    parser.add_argument("type", help="specify the entry type", default='TXT', choices=['A', 'AAAA', 'CNAME', 'MX', 'NS', 'SPF', 'SOA', 'TXT', 'SRV', 'LOC'])
+    parser.add_argument("type", help="specify the entry type", default='TXT', choices=['A', 'AAAA', 'CNAME', 'MX', 'NS', 'SOA', 'TXT', 'SRV', 'LOC'])
 
     parser.add_argument("--name", help="specify the record name")
     parser.add_argument("--content", help="specify the record content")
diff --git a/lexicon/client.py b/lexicon/client.py
--- a/lexicon/client.py
+++ b/lexicon/client.py
@@ -46,7 +46,9 @@ def _parse_env(self):
         for key in os.environ.keys():
             if key.startswith(env_prefix):
                 auth_type = key[len(env_prefix):].lower()
-                self.options['auth_{0}'.format(auth_type)] = self.options.get('auth_{0}'.format(auth_type), os.environ[key])
+                # only assign auth_username/token/etc if its not already provided by CLI.
+                if self.options.get('auth_{0}'.format(auth_type)) is None:
+                    self.options['auth_{0}'.format(auth_type)] = os.environ[key]
 
     def _validate(self, options):
         if not options.get('provider_name'):


Test patch:
Repository: AnalogJ/lexicon

Issue:
Case should be ignored when filtering records from digitalocean API
I noticed that digitalocean's HTTP API always returns `data` field of TXT records in lowercase, see [example](https://gist.github.com/jokester/e1152fd90ace2f71d767af1d96d802dc).

This can cause [lexicon](https://github.com/AnalogJ/lexicon/blob/b278cebf3f0cfba720b87b6ff9415969d524edc2/lexicon/providers/digitalocean.py#L58) to filter out the correct record and throw `Record identifier could not be found`.

Also [this error in issue #35](https://github.com/AnalogJ/lexicon/issues/35#issuecomment-213105616) seems to be related.



Discussion:

Resolving patch:
diff --git a/lexicon/providers/digitalocean.py b/lexicon/providers/digitalocean.py
--- a/lexicon/providers/digitalocean.py
+++ b/lexicon/providers/digitalocean.py
@@ -55,7 +55,7 @@ def list_records(self, type=None, name=None, content=None):
         if name:
             records = [record for record in records if record['name'] == self._full_name(name)]
         if content:
-            records = [record for record in records if record['content'] == content]
+            records = [record for record in records if record['content'].lower() == content.lower()]
 
         print 'list_records: {0}'.format(records)
         return records


Test patch:
Repository: AnalogJ/lexicon

Issue:
Gandi Records not picking up TTL
I'm trying to renew Lets Encrypt Certs using dehydrated, using lexicon to handle DNS modifications on a Gandi domain.  New challenge TXT records are being created with a TTL of 3 hours.  I have tried setting --ttl manually but they're always created with the default 3 hour TTL:

`lexicon gandi create platformservices.io TXT --name="testsubdomain.platformservices.io" --content="TEST" --ttl="120"`

Looks to me like the create_record method is missing the ttl property:

https://github.com/AnalogJ/lexicon/blob/master/lexicon/providers/gandi.py#L93


Discussion:

Resolving patch:
diff --git a/lexicon/providers/gandi.py b/lexicon/providers/gandi.py
--- a/lexicon/providers/gandi.py
+++ b/lexicon/providers/gandi.py
@@ -93,7 +93,9 @@ def create_record(self, type, name, content):
             self.api.domain.zone.record.add(self.apikey, self.zone_id, version,
                                             {'type': type.upper(),
                                              'name': name,
-                                             'value': content})
+                                             'value': content,
+                                             'ttl': self.options.get('ttl',self.default_ttl)
+                                            })
             self.api.domain.zone.version.set(self.apikey, self.zone_id, version)
             ret = True
 


Test patch:
Repository: AnalogJ/lexicon

Issue:
Fix logging TypeError (digitalocean.py)
[This same issue](https://github.com/AnalogJ/lexicon/pull/128/commits/903af58378ab9942d817c57e0330b5f7ac26b4e9) exists in `lexicon/providers/digitalocean.py` line 111. The same edit is needed to fix it. 

The error generated is:
```
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 861, in emit
    msg = self.format(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 734, in format
    return fmt.format(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 465, in format
    record.message = record.getMessage()
  File "/usr/lib/python2.7/logging/__init__.py", line 329, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Logged from file digitalocean.py, line 111
```
That section is:
```
 Line 110: # is always True at this point, if a non 200 response is returned an error is raised.
 Line 111: logger.debug('delete_record: {0}', True)
 Line 112: return True
```


Discussion:
damn. I wonder how many other places this has creeped in. 

Resolving patch:
diff --git a/lexicon/providers/digitalocean.py b/lexicon/providers/digitalocean.py
--- a/lexicon/providers/digitalocean.py
+++ b/lexicon/providers/digitalocean.py
@@ -108,7 +108,7 @@ def delete_record(self, identifier=None, type=None, name=None, content=None):
         payload = self._delete('/domains/{0}/records/{1}'.format(self.domain_id, identifier))
 
         # is always True at this point, if a non 200 response is returned an error is raised.
-        logger.debug('delete_record: {0}', True)
+        logger.debug('delete_record: %s', True)
         return True
 
 
diff --git a/lexicon/providers/dnsmadeeasy.py b/lexicon/providers/dnsmadeeasy.py
--- a/lexicon/providers/dnsmadeeasy.py
+++ b/lexicon/providers/dnsmadeeasy.py
@@ -107,7 +107,7 @@ def update_record(self, identifier, type=None, name=None, content=None):
 
         payload = self._put('/dns/managed/{0}/records/{1}'.format(self.domain_id, identifier), data)
 
-        logger.debug('update_record: {0}', True)
+        logger.debug('update_record: %s', True)
         return True
 
     # Delete an existing record.


Test patch:
Repository: AnalogJ/lexicon

Issue:
Namecheap support not optional
Unlike route53 or softlayer and unlike what setup.py suggests, the namecheap provider is not optional in 2.1.17.


Discussion:

Resolving patch:
diff --git a/lexicon/providers/namecheap.py b/lexicon/providers/namecheap.py
--- a/lexicon/providers/namecheap.py
+++ b/lexicon/providers/namecheap.py
@@ -3,10 +3,14 @@
 
 import logging
 
-import namecheap
 
 from .base import Provider as BaseProvider
 
+try:
+    import namecheap #optional dep
+except ImportError:
+    pass
+
 logger = logging.getLogger(__name__)
 
 


Test patch:
Repository: AnalogJ/lexicon

Issue:
GoDaddy provider should recognize domaincontrol.com as its nameserver
For the auto provider, it should recognize that domains managed by GoDaddy often have nameservers under the *.domaincontrol.com namespace.  You can verify this is GoDaddy via whois; and I also tested this by adding 'domaincontrol.com' to the recognized nameservers with the following patch.

```
--- providers/godaddy.py.orig	2020-01-09 08:58:26.160360574 +0000
+++ providers/godaddy.py	2020-01-10 19:27:29.292030195 +0000
@@ -14,5 +14,5 @@
 LOGGER = logging.getLogger(__name__)
 
-NAMESERVER_DOMAINS = ['godaddy.com']
+NAMESERVER_DOMAINS = ['godaddy.com','domaincontrol.com']
```

And the current whois excerpt:

```
$ whois domaincontrol.com
Domain Name: DOMAINCONTROL.COM
...
Updated Date: 2018-08-07T19:25:37Z
...
Registrant Organization: Go Daddy Operating Company, LLC
Registrant State/Province: Arizona
Registrant Country: US
```




Discussion:

Resolving patch:
diff --git a/lexicon/providers/godaddy.py b/lexicon/providers/godaddy.py
--- a/lexicon/providers/godaddy.py
+++ b/lexicon/providers/godaddy.py
@@ -13,7 +13,7 @@
 
 LOGGER = logging.getLogger(__name__)
 
-NAMESERVER_DOMAINS = ['godaddy.com']
+NAMESERVER_DOMAINS = ['godaddy.com', 'domaincontrol.com']
 
 
 def provider_parser(subparser):


Test patch:
Repository: AnalogJ/lexicon

Issue:
transip provider needs requests>=2.27.0 in dependency spec
The update of the transip provider from #1086 included in 3.9.2 uses `from requests.exceptions import JSONDecodeError` which was first included in requests 2.27.0 but the requirements spec only requires `>=2`:
https://github.com/AnalogJ/lexicon/blob/d8b26bcfffd484f34444c91ceb3ced4a2583bd18/pyproject.toml#L43

This is passed directly through to the requirement spec in the wheel:
```
Requires-Dist: requests (>=2)
```

And means that someone who upgrades dns-lexicon from a previous version using pip will get an import error.


Discussion:

Resolving patch:
diff --git a/lexicon/providers/transip.py b/lexicon/providers/transip.py
--- a/lexicon/providers/transip.py
+++ b/lexicon/providers/transip.py
@@ -11,7 +11,11 @@
 from cryptography.hazmat.primitives import hashes
 from cryptography.hazmat.primitives.asymmetric import padding
 from cryptography.hazmat.primitives.serialization import load_pem_private_key
-from requests.exceptions import JSONDecodeError
+
+try:
+    from simplejson import JSONDecodeError
+except ImportError:
+    from json import JSONDecodeError  # type: ignore[misc]
 
 from lexicon.exceptions import LexiconError
 from lexicon.providers.base import Provider as BaseProvider


Test patch:
Repository: AnalogJ/lexicon

Issue:
Bug in create action for glesys provider
When creating an A record with the glesys provider, the full name is added instead of the host name. 
```
lexicon_config = {
    "provider_name" : "glesys",
    "action": "create", 
    "domain": "somedomain.com",
    "type": "A",
    "name": "lexicon",
    "content": "1.2.3.4",
    "glesys": {
    }
}
```
Results in the A-record:
`{'id': 2723410, 'type': 'A', 'name': 'lexicon.somedomain.com', 'ttl': 3600, 'content': '1.2.3.4'}`

While the expected result is:
`{'id': 2723410, 'type': 'A', 'name': 'lexicon', 'ttl': 3600, 'content': '1.2.3.4'}`

The request data sent to `domain/addrecord` :
`{'domainname': 'somedomain.com', 'host': 'lexicon.somedomain.com', 'type': 'A', 'data': '1.2.3.4', 'ttl': 3600}`

Expected request data to `domain/addrecord`: 
`{'domainname': 'somedomain.com', 'host': 'lexicon', 'type': 'A', 'data': '1.2.3.4', 'ttl': 3600}`

Glesys API documentation:
```
domain/addrecord

Url: https://api.glesys.com/domain/addrecord

Method: Only Https POST

Required arguments: domainname , host , type , data

Optional arguments: ttl

Description: Adds a dns record to a domain
```



Discussion:

Resolving patch:
diff --git a/lexicon/providers/glesys.py b/lexicon/providers/glesys.py
--- a/lexicon/providers/glesys.py
+++ b/lexicon/providers/glesys.py
@@ -44,7 +44,7 @@ def _create_record(self, rtype, name, content):
 
         request_data = {
             "domainname": self.domain,
-            "host": self._full_name(name),
+            "host": name,
             "type": rtype,
             "data": content,
         }


Test patch:
Repository: apache/airflow

Issue:
Question: Can I set airflow configuration parameters from the environment?
I am running airflow under a heroku-like PaaS.  Can I somehow use environment variables to specify configuration like the `sql_alchemy_conn` and `broker_url` variables?



Discussion:

Resolving patch:
diff --git a/airflow/configuration.py b/airflow/configuration.py
--- a/airflow/configuration.py
+++ b/airflow/configuration.py
@@ -210,15 +210,25 @@ def get(self, section, key):
         section = str(section).lower()
         key = str(key).lower()
         d = self.defaults
-        try:
+
+        # environment variables get precedence
+        # must have format AIRFLOW__{SESTION}__{KEY} (note double underscore)
+        env_var = 'AIRFLOW__{S}__{K}'.format(S=section.upper(), K=key.upper())
+        if env_var in os.environ:
+            return os.environ[env_var]
+
+        # ...then the config file
+        elif self.has_option(section, key):
             return ConfigParser.get(self, section, key)
-        except:
-            if section not in d or key not in d[section]:
-                raise AirflowConfigException(
-                    "section/key [{section}/{key}] not found "
-                    "in config".format(**locals()))
-            else:
-                return d[section][key]
+
+        # ...then the defaults
+        elif section in d and key in d[section]:
+            return d[section][key]
+
+        else:
+            raise AirflowConfigException(
+                "section/key [{section}/{key}] not found "
+                "in config".format(**locals()))
 
     def getboolean(self, section, key):
         val = str(self.get(section, key)).lower().strip()


Test patch:
Repository: apache/airflow

Issue:
Trying to use a nonexistent pool fails silently
Looking at the `pool_full()` method of `TaskInstance` (line 818 of models.py) -- if the TI has a pool specified but the pool doesn't exist in the database, it returns False (and the run continues).

I think maybe if a pool was specified but doesn't exist, it should raise an error instead? After all, the point of a pool is to restrict execution and this behavior lets it go on (silently).



Discussion:

Resolving patch:
diff --git a/airflow/models.py b/airflow/models.py
--- a/airflow/models.py
+++ b/airflow/models.py
@@ -816,7 +816,8 @@ def pool_full(self, session):
             .first()
         )
         if not pool:
-            return False
+            raise ValueError('Task specified a pool ({}) but the pool '
+                             'doesn\'t exist!').format(self.task.pool)
         open_slots = pool.open_slots(session=session)
 
         return open_slots <= 0


Test patch:
Repository: apache/airflow

Issue:
Editing a jdbc connection in 1.5.1 throws internal server error
Editing an existing jdbc connection results in:

```
File "/usr/local/lib/python2.7/site-packages/airflow-1.5.1-py2.7.egg/airflow/www/app.py", line 1765, in on_form_prefill
    field = getattr(form, field)
AttributeError: 'ConnectionForm' object has no attribute 'extra__jdbc__drv_path'
```

At the same time creating a new jdbc connection doesn't show the extra form fields anymore.



Discussion:

Resolving patch:
diff --git a/airflow/www/app.py b/airflow/www/app.py
--- a/airflow/www/app.py
+++ b/airflow/www/app.py
@@ -1696,6 +1696,8 @@ class ConnectionModelView(wwwutils.SuperUserMixin, AirflowModelView):
         'password',
         'port',
         'extra',
+        'extra__jdbc__drv_path',
+        'extra__jdbc__drv_clsname',
     )
     verbose_name = "Connection"
     verbose_name_plural = "Connections"


Test patch:
Repository: apache/airflow

Issue:
Broken Tree View
We are using version 1.5.1 of Airflow.

I am seeing the following issue with Tree View. Steps:
1. Go to http://my-airflow-instance.com/admin/
2. Click on Tree View for any DAG.
3. In the Tree View, click on `Go` button in the Tree form.
4. 500 page with this stack trace:

```
2015-09-22_23:19:02.61708 2015-09-22 23:19:02,616 - tornado.access - ERROR - 500 GET /admin/airflow/tree?base_date=2015-09-23+17%3A00%3A00&num_runs=25&root=None&dag_id=summarize_hourly (172.17.42.1) 15.79ms
2015-09-22_23:24:43.09539 2015-09-22 23:24:43,095 - airflow.www.app - ERROR - Exception on /admin/airflow/tree [GET]
2015-09-22_23:24:43.09552 Traceback (most recent call last):
2015-09-22_23:24:43.09557   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app
2015-09-22_23:24:43.09561     response = self.full_dispatch_request()
2015-09-22_23:24:43.09565   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1477, in full_dispatch_request
2015-09-22_23:24:43.09568     rv = self.handle_user_exception(e)
2015-09-22_23:24:43.09570   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1381, in handle_user_exception
2015-09-22_23:24:43.09570     reraise(exc_type, exc_value, tb)
2015-09-22_23:24:43.09570   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in full_dispatch_request
2015-09-22_23:24:43.09571     rv = self.dispatch_request()
2015-09-22_23:24:43.09571   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1461, in dispatch_request
2015-09-22_23:24:43.09572     return self.view_functions[rule.endpoint](**req.view_args)
2015-09-22_23:24:43.09575   File "/usr/local/lib/python2.7/dist-packages/flask_admin/base.py", line 68, in inner
2015-09-22_23:24:43.09576     return self._run_view(f, *args, **kwargs)
2015-09-22_23:24:43.09578   File "/usr/local/lib/python2.7/dist-packages/flask_admin/base.py", line 359, in _run_view
2015-09-22_23:24:43.09579     return fn(self, *args, **kwargs)
2015-09-22_23:24:43.09581   File "/usr/local/lib/python2.7/dist-packages/airflow/www/utils.py", line 96, in view_func
2015-09-22_23:24:43.09583     return f(*args, **kwargs)
2015-09-22_23:24:43.09584   File "/usr/local/lib/python2.7/dist-packages/airflow/www/app.py", line 1070, in tree
2015-09-22_23:24:43.09585     node_limit = 5000 / len(dag.roots)
2015-09-22_23:24:43.09587 ZeroDivisionError: division by zero
```



Discussion:

Resolving patch:
diff --git a/airflow/www/app.py b/airflow/www/app.py
--- a/airflow/www/app.py
+++ b/airflow/www/app.py
@@ -1085,7 +1085,7 @@ def tree(self):
         # expand/collapse functionality. After 5,000 nodes we stop and fall
         # back on a quick DFS search for performance. See PR #320.
         node_count = [0]
-        node_limit = 5000 / len(dag.roots)
+        node_limit = 5000 / max(1, len(dag.roots))
 
         def recurse_nodes(task, visited):
             visited.add(task)


Test patch:
Repository: apache/airflow

Issue:
BUG: missing status graphics for dag_ids with periods
Based on some experimentation, it looks like status circles on the main web server page don't appear for `dag_id`s that contain periods. Changing a dag_id from `test.dag` to `test_dag` was enough to make the circles reappear. Since I can see the dag_stats json is generated correctly, perhaps this is a problem with how d3 interprets the json? 

These are the circles I mean (note the missing middle row):
![screen shot 2015-09-20 at 11 25 46 pm](https://cloud.githubusercontent.com/assets/153965/9984897/f3660ade-5fee-11e5-8a12-fcc4394b41c2.png)



Discussion:
Can confirm -- it's because the svg id can't contain periods. One hack that seems to work is to replace `".`' with `"__dot__"` in the dag_id string. 


Resolving patch:
diff --git a/airflow/models.py b/airflow/models.py
--- a/airflow/models.py
+++ b/airflow/models.py
@@ -1870,6 +1870,7 @@ def __init__(
         self.template_searchpath = template_searchpath
         self.parent_dag = None  # Gets set when DAGs are loaded
         self.last_loaded = datetime.now()
+        self.safe_dag_id = dag_id.replace('.', '__dot__')
 
         self._comps = {
             'dag_id',
diff --git a/airflow/www/app.py b/airflow/www/app.py
--- a/airflow/www/app.py
+++ b/airflow/www/app.py
@@ -683,7 +683,7 @@ def dag_stats(self):
 
         payload = {}
         for dag in dagbag.dags.values():
-            payload[dag.dag_id] = []
+            payload[dag.safe_dag_id] = []
             for state in states:
                 try:
                     count = data[dag.dag_id][state]
@@ -695,7 +695,7 @@ def dag_stats(self):
                     'dag_id': dag.dag_id,
                     'color': State.color(state)
                 }
-                payload[dag.dag_id].append(d)
+                payload[dag.safe_dag_id].append(d)
         return Response(
             response=json.dumps(payload, indent=4),
             status=200, mimetype="application/json")


Test patch: