internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: fossasia/open-event-server

Issue:
IOError: cannot identify image file <cStringIO.StringI object at 0x7fc26db50a48>
https://sentry.eventyay.com/eventyay/dev-api/issues/49/

```
IOError: cannot identify image file <cStringIO.StringI object at 0x7fc26db50a48>
(15 additional frame(s) were not displayed)
...
  File "app/api/helpers/permissions.py", line 43, in decorator
    return fn(*args, **kwargs)
  File "app/api/helpers/permission_manager.py", line 58, in is_coorganizer
    return view(*view_args, **view_kwargs)
  File "app/api/events.py", line 322, in before_update_object
    uploaded_images = create_save_image_sizes(data['original_image_url'], 'event', event.id)
  File "app/api/helpers/files.py", line 156, in create_save_image_sizes
    'original_image_url': create_save_resized_image(image_file, 0, 0, 0, original_upload_path, resize=False),
  File "app/api/helpers/files.py", line 77, in create_save_resized_image
    im = Image.open(image_file)

IOError: cannot identify image file <cStringIO.StringI object at 0x7fc26db50a48>
```


Discussion:
@shubham-padia I am working on this but had a doubt.
I have figured out that to reproduce the error, the user has to be the coorganizer of an event and when he tries to upload an image for the event, the error should occur.If the above mentioned is correct,
I have created a role-invite but how do I get my user to accept it? or else what should be the approach to reproduce the error

Resolving patch:
diff --git a/app/api/helpers/files.py b/app/api/helpers/files.py
--- a/app/api/helpers/files.py
+++ b/app/api/helpers/files.py
@@ -74,7 +74,10 @@ def create_save_resized_image(image_file, basewidth=None, maintain_aspect=None,
     """
     filename = '{filename}.{ext}'.format(filename=get_file_name(), ext=ext)
     image_file = cStringIO.StringIO(urllib.urlopen(image_file).read())
-    im = Image.open(image_file)
+    try:
+        im = Image.open(image_file)
+    except IOError:
+        raise IOError("Corrupt/Invalid Image")
 
     # Convert to jpeg for lower file size.
     if im.format is not 'JPEG':


Test patch:
Repository: fossasia/open-event-server

Issue:
TypeError: __init__() got an unexpected keyword argument 'created_at'
https://sentry.eventyay.com/eventyay/dev-api/issues/99/

```
TypeError: __init__() got an unexpected keyword argument 'created_at'
(8 additional frame(s) were not displayed)
...
  File "app/api/helpers/permissions.py", line 43, in decorator
    return fn(*args, **kwargs)

TypeError: __init__() got an unexpected keyword argument 'created_at'
```


Discussion:
I want to claim this issue.
Don't say it exactly claiming and yeah feel free to work on it. Make sure you have the setup ready.
Yes I have the setup ready. I will come back with possible solution.
@shubham-padia @poush Can you help me to reproduce this error ? `jwt-required` in permissions.py is called in multiple no of cases and I can't figure which case is causing this error.
@ananyo2012 The error is occurring in the discount codes API.
It maybe a bug in the discount code sqlalchemy model constructor proabably, please check that first.
I checked the Discount code model but couldn't find any bug in it. Any other leads in figuring out the error?
@ananyo2012 Are you working in this?

Yes I am. But I am unable to figure out the error. Would be great if you can help in reproducing the error !
can I see your request?
@ananyo2012 Still working?
Yes I am working on it. I kinda missed your last comment. Will send the request I made in a minute
Working from 24 days?
Ok I was finally able to reproduce the error. This is happening when we try to explicitly pass a `created_at` parameter in the Discount Codes request while creating a new discount code. But if we don't give a `created_at` parameter it by default takes the current time.

Resolving patch:
diff --git a/app/models/discount_code.py b/app/models/discount_code.py
--- a/app/models/discount_code.py
+++ b/app/models/discount_code.py
@@ -40,6 +40,7 @@ def __init__(self,
                  valid_from=None,
                  valid_till=None,
                  is_active=True,
+                 created_at=None,
                  used_for=None,
                  event_id=None,
                  tickets=None,


Test patch:
Repository: fossasia/open-event-server

Issue:
Update installation/deployment instructions.
**I'm submitting a ...**  (check one with "x")
- [x] bug report
- [ ] feature request
- [ ] support request => Please do not submit support requests here, instead ask your query in out Gitter channel at https://gitter.im/fossasia/open-event-orga-server

**Current behavior:**
Currently in all the installation/deployment instructions there are many instances where `open-event-orga-server` still persists which can create confusion while following the instructions.


**Expected behavior:**
`open-event-orga-server` needs to be replaced with `open-event-server`at many instances in installation/deployment docs.


**Steps to reproduce:**
Check out the documentation of different installations/deployments.
https://github.com/fossasia/open-event-server/tree/development/docs/installation and https://github.com/fossasia/open-event-server/tree/development/docs


Discussion:
please give the path to the file for easy access.

You might want to look [here](https://github.com/fossasia/open-event-api/tree/development/docs/installation)
All the installation/deployment docs can be found here.
@SaptakS @niranjan94  if you could please add the appropriate labels so that it is easier for new contributors to check this out. Thanks.
Claiming this!
Changing all the occurrences of `open-event-orga-server` to `open-event-server` .

Resolving patch:
diff --git a/app/__init__.py b/app/__init__.py
--- a/app/__init__.py
+++ b/app/__init__.py
@@ -113,7 +113,7 @@ def create_app():
         # Profiling
         app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[30])
 
-    # nextgen api
+    # development api
     with app.app_context():
         from app.api.bootstrap import api_v1
         from app.api.uploads import upload_routes
diff --git a/app/views/__init__.py b/app/views/__init__.py
--- a/app/views/__init__.py
+++ b/app/views/__init__.py
@@ -87,7 +87,7 @@ def index():
     Index route
     :return:
     """
-    r = requests.get('https://raw.githubusercontent.com/fossasia/open-event-orga-server/gh-pages/api/v1/index.html')
+    r = requests.get('https://raw.githubusercontent.com/fossasia/open-event-server/gh-pages/api/v1/index.html')
     response = make_response(r.content)
     response.headers["Content-Type"] = "text/html"
     return response


Test patch:
Repository: fossasia/open-event-server

Issue:
reset-password end point should return 422 status, when non existing email address is provided
**I'm submitting a ...**  (check one with "x")
- [x] bug report
- [ ] feature request
- [ ] support request => Please do not submit support requests here, instead ask your query in out Gitter channel at https://gitter.im/fossasia/open-event-server

**Current behavior:**
<!-- Describe how the bug manifests. -->
It returns a 404.
![image](https://user-images.githubusercontent.com/17252805/34255775-3376997e-e678-11e7-8f84-98efd0444f51.png)

**Expected behavior:**
<!-- Describe what the behavior would be without the bug. -->
It should return 422.



Discussion:
I would like to work on this issue

Resolving patch:
diff --git a/app/api/auth.py b/app/api/auth.py
--- a/app/api/auth.py
+++ b/app/api/auth.py
@@ -52,7 +52,7 @@ def reset_password_post():
         user = User.query.filter_by(email=email).one()
     except NoResultFound:
         return abort(
-            make_response(jsonify(error="User not found"), 404)
+            make_response(jsonify(error="User not found"), 422)
         )
     else:
         link = make_frontend_url('/reset-password', {'token': user.reset_password})


Test patch:
Repository: fossasia/open-event-server

Issue:
Add missing date validation to discount-code API
**I'm submitting a ...**  (check one with "x")
- [x] bug report
- [ ] feature request
- [ ] support request => Please do not submit support requests here, instead ask your query in out Gitter channel at https://gitter.im/fossasia/open-event-server

**Current behavior:**
Validation of date is missing in the discount-code API. 

**Expected behavior:**
<!-- Describe what the behavior would be without the bug. -->
The validation similar to the one in access-code API to validate date should be added.





Discussion:

Resolving patch:
diff --git a/app/api/schema/discount_codes.py b/app/api/schema/discount_codes.py
--- a/app/api/schema/discount_codes.py
+++ b/app/api/schema/discount_codes.py
@@ -76,6 +76,21 @@ def validate_quantity(self, data, original_data):
                 raise UnprocessableEntity({'pointer': '/data/attributes/tickets-number'},
                                           "tickets-number should be greater than max-quantity")
 
+    @validates_schema(pass_original=True)
+    def validate_date(self, data, original_data):
+        if 'id' in original_data['data']:
+            discount_code = DiscountCode.query.filter_by(id=original_data['data']['id']).one()
+
+            if 'valid_from' not in data:
+                data['valid_from'] = discount_code.valid_from
+
+            if 'valid_till' not in data:
+                data['valid_till'] = discount_code.valid_till
+
+        if data['valid_from'] >= data['valid_till']:
+            raise UnprocessableEntity({'pointer': '/data/attributes/valid-till'},
+                                      "valid_till should be after valid_from")
+
     events = Relationship(attribute='events',
                           self_view='v1.discount_code_events',
                           self_view_kwargs={'id': '<id>'},
@@ -120,6 +135,21 @@ def validate_quantity(self, data, original_data):
                 raise UnprocessableEntity({'pointer': '/data/attributes/tickets-number'},
                                           "tickets-number should be greater than max-quantity")
 
+    @validates_schema(pass_original=True)
+    def validate_date(self, data, original_data):
+        if 'id' in original_data['data']:
+            discount_code = DiscountCode.query.filter_by(id=original_data['data']['id']).one()
+
+            if 'valid_from' not in data:
+                data['valid_from'] = discount_code.valid_from
+
+            if 'valid_till' not in data:
+                data['valid_till'] = discount_code.valid_till
+
+        if data['valid_from'] >= data['valid_till']:
+            raise UnprocessableEntity({'pointer': '/data/attributes/valid-till'},
+                                      "valid_till should be after valid_from")
+
     marketer = Relationship(attribute='user',
                             self_view='v1.discount_code_user',
                             self_view_kwargs={'id': '<id>'},


Test patch:
Repository: fossasia/open-event-server

Issue:
New deployment: app not working due to empty settings table



Discussion:

Resolving patch:
diff --git a/populate_db.py b/populate_db.py
--- a/populate_db.py
+++ b/populate_db.py
@@ -23,6 +23,8 @@
 from app.models.panel_permission import PanelPermission
 from app.models.custom_system_role import CustomSysRole
 
+from app.models.setting import Setting
+
 # User Permissions
 from app.models.user_permission import UserPermission
 SALES = 'sales'
@@ -51,6 +53,10 @@ def create_services():
     get_or_create(Service, name=microlocation)
 
 
+def create_settings():
+    get_or_create(Setting, app_name='Open Event')
+
+
 def create_permissions():
     orgr = Role.query.get(1)
     coorgr = Role.query.get(2)
@@ -168,6 +174,8 @@ def populate():
     create_panel_permissions()
     print('Creating user permissions...')
     create_user_permissions()
+    print('Creating settings...')
+    create_settings()
     print('Creating admin message settings...')
     create_admin_message_settings()
 


Test patch:
Repository: fossasia/open-event-server

Issue:
Generated reset password link is correct but not clickable
**I'm submitting a ...**  (check one with "x")
- [x] bug report
- [ ] feature request
- [ ] support request => Please do not submit support requests here, instead ask your query in out Gitter channel at https://gitter.im/fossasia/open-event-server

**Current behavior:**
<!-- Describe how the bug manifests. -->
![image](https://user-images.githubusercontent.com/17252805/35488202-a4284b54-04aa-11e8-981a-f8bf29de8615.png)
The link appears as static text in the email.
**Expected behavior:**
<!-- Describe what the behavior would be without the bug. -->
The link should be clickable.



Discussion:
@CosmicCoder96 Can I help fix this issue? 
@Riyuzakii Please go ahead.
@sumedh123 do you mind giving me some directions, I'm kind of a newbie?
@CosmicCoder96 it has been working normally for me. Please check again
![screenshot from 2018-02-01 00-41-05](https://user-images.githubusercontent.com/19731697/35642411-0973550e-06e9-11e8-8190-1bebfc301ddf.png)

@prshntsingh weird, I have two mails. One shows the link as a hyperlink, other doesn't. 
![image](https://user-images.githubusercontent.com/17252805/35720727-eeb4bc80-0814-11e8-8885-ac2414a1815f.png)

Both have been rendered differently. 
![image](https://user-images.githubusercontent.com/17252805/35720734-f7dbc3bc-0814-11e8-8b9f-2064c9e58f98.png)

@CosmicCoder96 Can I work on this issue?

Resolving patch:
diff --git a/app/api/helpers/system_mails.py b/app/api/helpers/system_mails.py
--- a/app/api/helpers/system_mails.py
+++ b/app/api/helpers/system_mails.py
@@ -111,7 +111,7 @@
         'recipient': 'User',
         'subject': u'{app_name}: Password Reset',
         'message': (
-            u"Please use the following link to reset your password.<br> {link}"
+            u"Please use the following link to reset your password.<br> <a href='{link}' target='_blank'>{link}</a>"
         )
     },
     PASSWORD_CHANGE: {


Test patch:
Repository: fossasia/open-event-server

Issue:
Unable to create feedback object through api endpoint
- [x] bug report
- [ ] feature request
- [ ] support request => Please do not submit support requests here, instead ask your query in out Gitter channel at https://gitter.im/fossasia/open-event-server

**Current behavior:**
Unable to create new feedback with my user id and event id

**Expected behavior:**
should be able to create new feedback with my event id

**Related code:**
error
```
{
    "jsonapi": {
        "version": "1.0"
    },
    "errors": [
        {
            "detail": "User: 7 doesn't match auth key",
            "status": 404,
            "source": {
                "parameter": "user_id"
            },
            "title": "Object not found"
        }
    ]
}
```




Discussion:
@iamareebjamal can you have a look at this please.
Please confirm that you are using https://open-event-api-dev.herokuapp.com

Also, you issue description does not match the issue title. Please clarify
@iamareebjamal yes i used  https://open-event-api-dev.herokuapp.com
and sorry for the ambiguity, i have made changes in the description 

Resolving patch:
diff --git a/app/api/feedbacks.py b/app/api/feedbacks.py
--- a/app/api/feedbacks.py
+++ b/app/api/feedbacks.py
@@ -27,7 +27,7 @@ def before_post(self, args, kwargs, data):
         :return:
         """
         require_relationship(['event', 'user'], data)
-        if not has_access('is_user_itself', id=data['user']):
+        if not has_access('is_user_itself', id=int(data['user'])):
             raise ObjectNotFound({'parameter': 'user_id'},
                                  "User: {} doesn't match auth key".format(data['user']))
 


Test patch:
Repository: fossasia/open-event-server

Issue:
Recursive method for generating event ID does not respect length
**I'm submitting a ...**  (check one with "x")
- [x] bug report
- [ ] feature request
- [ ] support request => Please do not submit support requests here, instead ask your query in out Gitter channel at https://gitter.im/fossasia/open-event-server

In model `event.py`

```python
def get_new_event_identifier(length=8):
    identifier = binascii.b2a_hex(os.urandom(length / 2))
    count = get_count(Event.query.filter_by(identifier=identifier))
    if count == 0:
        return identifier
    else:
        return get_new_event_identifier()
```

The recursive call does not pass on the passed argument `length` which will lead to wrong length identifier being generated


Discussion:

Resolving patch:
diff --git a/app/models/event.py b/app/models/event.py
--- a/app/models/event.py
+++ b/app/models/event.py
@@ -15,12 +15,12 @@
 
 
 def get_new_event_identifier(length=8):
-    identifier = binascii.b2a_hex(os.urandom(length / 2))
+    identifier = binascii.b2a_hex(os.urandom(int(length / 2)))
     count = get_count(Event.query.filter_by(identifier=identifier))
     if count == 0:
         return identifier
     else:
-        return get_new_event_identifier()
+        return get_new_event_identifier(length)
 
 
 class Event(db.Model):


Test patch:
Repository: fossasia/open-event-server

Issue:
Remove SERVER_NAME or add warning in docs
The `SERVER_NAME` config in example env shadows the possible IP addresses a machine may take. For example, if the local IP is `10.0.3.2` the SERVER_NAME parameter being set to `localhost` will shadow this and 404 error will be shown instead.

This setting should either be removed or a warning should be added in the docs as it can be quite painful to pin point what the issue is


Discussion:
I am working on this .

Resolving patch:
diff --git a/config.py b/config.py
--- a/config.py
+++ b/config.py
@@ -49,7 +49,8 @@ class Config(object):
     SQLALCHEMY_TRACK_MODIFICATIONS = True
     ERROR_404_HELP = False
     CSRF_ENABLED = True
-    SERVER_NAME = env('SERVER_NAME', default=None)
+    SERVER_NAME = env('SERVER_NAME', default='127.0.0.1:5000')
+    FALLBACK_PORT = 80
     CORS_HEADERS = 'Content-Type'
     SQLALCHEMY_DATABASE_URI = env('DATABASE_URL', default=None)
     SERVE_STATIC = env.bool('SERVE_STATIC', default=False)
diff --git a/manage.py b/manage.py
--- a/manage.py
+++ b/manage.py
@@ -1,5 +1,5 @@
 from __future__ import print_function
-
+from flask_script import Server
 import os
 
 from app.api.helpers.db import save_to_db
@@ -94,4 +94,8 @@ def prepare_kubernetes_db():
 
 
 if __name__ == "__main__":
+    host_port = app.config['SERVER_NAME'].split(":")
+    host = host_port[0]
+    port = int(host_port[1] if len(host_port) > 1 else app.config['FALLBACK_PORT'])
+    manager.add_command("runserver", Server(host=host, port=port))
     manager.run()


Test patch:
Repository: fossasia/open-event-server

Issue:
Server is not found locally after #4643
**I'm submitting a ...**  (check one with "x")
- [x] bug report
- [ ] feature request
- [ ] support request => Please do not submit support requests here, instead ask your query in out Gitter channel at https://gitter.im/fossasia/open-event-server

After #4643, the server cannot be accessed via the URL `localhost:5000` or any other means. This has lead to Travis build failing and inability to test things locally as well. Revert this behaviour and reopen the original issue


Discussion:

Resolving patch:
diff --git a/config.py b/config.py
--- a/config.py
+++ b/config.py
@@ -49,8 +49,7 @@ class Config(object):
     SQLALCHEMY_TRACK_MODIFICATIONS = True
     ERROR_404_HELP = False
     CSRF_ENABLED = True
-    SERVER_NAME = env('SERVER_NAME', default='127.0.0.1:5000')
-    FALLBACK_PORT = 80
+    SERVER_NAME = env('SERVER_NAME', default=None)
     CORS_HEADERS = 'Content-Type'
     SQLALCHEMY_DATABASE_URI = env('DATABASE_URL', default=None)
     SERVE_STATIC = env.bool('SERVE_STATIC', default=False)
diff --git a/manage.py b/manage.py
--- a/manage.py
+++ b/manage.py
@@ -1,5 +1,4 @@
 from __future__ import print_function
-from flask_script import Server
 import os
 
 from app.api.helpers.db import save_to_db
@@ -94,8 +93,4 @@ def prepare_kubernetes_db():
 
 
 if __name__ == "__main__":
-    host_port = app.config['SERVER_NAME'].split(":")
-    host = host_port[0]
-    port = int(host_port[1] if len(host_port) > 1 else app.config['FALLBACK_PORT'])
-    manager.add_command("runserver", Server(host=host, port=port))
     manager.run()


Test patch:
Repository: fossasia/open-event-server

Issue:
No reference validation for attendee and ticket relationship
**I'm submitting a ...**  (check one with "x")
- [x] bug report
- [ ] feature request
- [ ] support request => Please do not submit support requests here, instead ask your query in out Gitter channel at https://gitter.im/fossasia/open-event-server

**Current behavior:**
Someone can add a reference to another event's ticket to an attendee on some other event

Event 155 has tickets 223 and 221

I can create an attendee with ticket 233 for event 255, where ticket 233 does not belong to the event 255

This causes serious referential integrity problems in mobile clients

**Expected behavior:**
Reference should be checked before persisting in database

**Steps to reproduce:**
```JSON
{
  "data": {
    "attributes": {
      "firstname": "Payer",
      "lastname": "Rich",
      "email": "payer.rich@example.com",
      "address": "address",
      "city": "example",
      "state": "example",
      "country": "IN",
      "is-checked_in": "false",
      "pdf-url": "http://example.com"
    },
    "type": "attendee",
    "relationships": {
      "event": { "data" : { "type" : "event", "id" : "{{event}}" } },
      "ticket": { "data" : { "type" : "ticket", "id" : "233" } }
    }
  }
}
```



Discussion:
@Masquerade0097 Can you please take it up
Yes.

Resolving patch:
diff --git a/app/api/attendees.py b/app/api/attendees.py
--- a/app/api/attendees.py
+++ b/app/api/attendees.py
@@ -31,6 +31,12 @@ def before_post(self, args, kwargs, data):
         """
         require_relationship(['ticket', 'event'], data)
 
+        ticket = db.session.query(Ticket).filter_by(id=int(data['ticket'])).first()
+        if ticket is None:
+            raise UnprocessableEntity({'pointer': '/data/relationships/ticket'}, "Invalid Ticket")
+        if ticket.event_id != int(data['event']):
+            raise UnprocessableEntity({'pointer': '/data/relationships/ticket'}, "Ticket belongs to a different Event")
+
     decorators = (jwt_required,)
     methods = ['POST']
     schema = AttendeeSchema


Test patch: