fossasia / open-event-server

The Open Event Organizer Server to Manage Events https://test-api.eventyay.com
https://api.eventyay.com
GNU General Public License v3.0
2.97k stars 1.89k forks source link

Events API: Adding original-image-url to payload gives Error 503 #4380

Closed dilpreetsio closed 6 years ago

dilpreetsio commented 7 years ago

I'm submitting a ... (check one with "x")

API Endpoint

PATCH/POST : v1/events

Payload

{
   "data":{
      "attributes":{
         "name":"TEST",
         "description":"",
         "starts-at":"2017-09-17T18:30:00.000Z",
         "ends-at":"2017-09-18T11:30:43.608Z",
         "timezone":"Asia/Calcutta",
         "location-name":"Delhi, India",
         "searchable-location-name":null,
         "longitude":77.1024901999999,
         "latitude":28.7040592,
         "logo-url":"https://open-event-api.herokuapp.com/static/media/temp/images/fb562d74-3b15-42eb-be66-98d858c0b2c6/c1gvbHV6Mm/630268fb-3e8f-4844-9a75-a8a4c85bb2a1.jpeg",
         "original-image-url":"https://open-event-api.herokuapp.com/static/media/temp/images/7e5d3916-57c3-4cf1-94fe-a8b9a8fc75dd/K2dLeGFOVU/7d9b23a2-bbf8-4d1d-94ac-4e5f610b2a03.png",
         "is-map-shown":true,
         "is-sponsors-enabled":false,
         "is-ticketing-enabled":true,
         "is-sessions-speakers-enabled":false,
         "is-tax-enabled":false,
         "can-pay-by-paypal":false,
         "can-pay-by-stripe":false,
         "can-pay-by-cheque":false,
         "can-pay-by-bank":false,
         "can-pay-onsite":false,
         "payment-country":null,
         "payment-currency":"USD",
         "paypal-email":null,
         "cheque-details":null,
         "bank-details":null,
         "onsite-details":null,
         "has-organizer-info":false,
         "organizer-name":null,
         "organizer-description":"",
         "external-event-url":null,
         "ticket-url":null,
         "code-of-conduct":"",
         "state":"draft",
         "privacy":"public"
      },
      "type":"event",
      "id":"299"
   }
}

ERROR

503 Service Unavailable
shubham-padia commented 7 years ago

Not a bug, maybe an issue from the side of heroku, please try again. https://httpstatuses.com/503

dilpreetsio commented 7 years ago

@shubham-padia Okay but it does not happen when we add logo-url, the problem also persists for custom-placeholder API

shubham-padia commented 7 years ago

I don't get it :sweat_smile: , please rephrase :)

dilpreetsio commented 7 years ago

Error 503 only occurs when we try to add original-image-url, however when we try to add logo-url in events API it works. The same problem also occurs in custom-placeholder API. Its strange!

SaptakS commented 7 years ago

@shubham-padia not exactly an heroku server problem. This is the heroku logs.

2017-08-19T07:35:16.454003+00:00 app[web.1]: Exception on /v1/events/3c4b51ec [PATCH]
2017-08-19T07:35:16.453927+00:00 app[web.1]:     im = Image.open(image_file)
2017-08-19T07:35:16.454004+00:00 app[web.1]: Traceback (most recent call last):
2017-08-19T07:35:16.453928+00:00 app[web.1]:     % (filename if filename else fp))
2017-08-19T07:35:16.454004+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
2017-08-19T07:35:16.454005+00:00 app[web.1]:     response = self.full_dispatch_request()
2017-08-19T07:35:16.454005+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
2017-08-19T07:35:16.454005+00:00 app[web.1]:     rv = self.handle_user_exception(e)
2017-08-19T07:35:16.454006+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask_cors/extension.py", line 161, in wrapped_function
2017-08-19T07:35:16.454006+00:00 app[web.1]:     return cors_after_request(app.make_response(f(*args, **kwargs)))
2017-08-19T07:35:16.454007+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
2017-08-19T07:35:16.454007+00:00 app[web.1]:     reraise(exc_type, exc_value, tb)
2017-08-19T07:35:16.454007+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
2017-08-19T07:35:16.454008+00:00 app[web.1]:     rv = self.dispatch_request()
2017-08-19T07:35:16.454008+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
2017-08-19T07:35:16.454008+00:00 app[web.1]:     return self.view_functions[rule.endpoint](**req.view_args)
2017-08-19T07:35:16.454009+00:00 app[web.1]:   File "/app/.heroku/src/flask-rest-jsonapi/flask_rest_jsonapi/api.py", line 133, in decorated
2017-08-19T07:35:16.454009+00:00 app[web.1]:     return self.check_permissions(view, view_args, view_kwargs, *args, **kwargs)
2017-08-19T07:35:16.454009+00:00 app[web.1]:   File "/app/app/api/helpers/permission_manager.py", line 436, in permission_manager
2017-08-19T07:35:16.454010+00:00 app[web.1]:     return permissions[args[0]](view, view_args, view_kwargs, *args, **kwargs)
2017-08-19T07:35:16.454010+00:00 app[web.1]:   File "/app/app/api/helpers/permissions.py", line 43, in decorator
2017-08-19T07:35:16.454011+00:00 app[web.1]:     return fn(*args, **kwargs)
2017-08-19T07:35:16.454011+00:00 app[web.1]:   File "/app/app/api/helpers/permission_manager.py", line 58, in is_coorganizer
2017-08-19T07:35:16.454011+00:00 app[web.1]:     return view(*view_args, **view_kwargs)
2017-08-19T07:35:16.454012+00:00 app[web.1]:   File "/app/.heroku/src/flask-rest-jsonapi/flask_rest_jsonapi/decorators.py", line 32, in wrapper
2017-08-19T07:35:16.454012+00:00 app[web.1]:     return func(*args, **kwargs)
2017-08-19T07:35:16.454013+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/flask/views.py", line 84, in view
2017-08-19T07:35:16.454013+00:00 app[web.1]:     return self.dispatch_request(*args, **kwargs)
2017-08-19T07:35:16.454013+00:00 app[web.1]:   File "/app/.heroku/src/flask-rest-jsonapi/flask_rest_jsonapi/resource.py", line 68, in dispatch_request
2017-08-19T07:35:16.454014+00:00 app[web.1]:     response = method(*args, **kwargs)
2017-08-19T07:35:16.454014+00:00 app[web.1]:   File "/app/.heroku/src/flask-rest-jsonapi/flask_rest_jsonapi/decorators.py", line 56, in wrapper
2017-08-19T07:35:16.454014+00:00 app[web.1]:     return func(*args, **kwargs)
2017-08-19T07:35:16.454015+00:00 app[web.1]:   File "/app/.heroku/src/flask-rest-jsonapi/flask_rest_jsonapi/resource.py", line 300, in patch
2017-08-19T07:35:16.454015+00:00 app[web.1]:     self._data_layer.update_object(obj, data, kwargs)
2017-08-19T07:35:16.454015+00:00 app[web.1]:   File "/app/.heroku/src/flask-rest-jsonapi/flask_rest_jsonapi/data_layers/alchemy.py", line 126, in update_object
2017-08-19T07:35:16.454016+00:00 app[web.1]:     self.before_update_object(obj, data, view_kwargs)
2017-08-19T07:35:16.454016+00:00 app[web.1]:   File "/app/app/api/events.py", line 301, in before_update_object
2017-08-19T07:35:16.454016+00:00 app[web.1]:     uploaded_images = create_save_image_sizes(data['original_image_url'], 'event', event.id)
2017-08-19T07:35:16.454017+00:00 app[web.1]:   File "/app/app/api/helpers/files.py", line 156, in create_save_image_sizes
2017-08-19T07:35:16.454017+00:00 app[web.1]:     'original_image_url': create_save_resized_image(image_file, 0, 0, 0, original_upload_path, resize=False),
2017-08-19T07:35:16.454018+00:00 app[web.1]:   File "/app/app/api/helpers/files.py", line 77, in create_save_resized_image
2017-08-19T07:35:16.454018+00:00 app[web.1]:     im = Image.open(image_file)
2017-08-19T07:35:16.454018+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/PIL/Image.py", line 2319, in open
2017-08-19T07:35:16.454019+00:00 app[web.1]:     % (filename if filename else fp))
2017-08-19T07:35:16.454019+00:00 app[web.1]: IOError: cannot identify image file <cStringIO.StringI object at 0x7f35b3349f10>

@poush @magdalenesuo @enigmaeth please look into this. I face the same issue in local system also.

poush commented 7 years ago

@geekyd Testing on my local system. Can you share the sample orginal_image_url, the one you are trying?

dilpreetsio commented 7 years ago

@poush https://open-event-api.herokuapp.com/static/media/temp/images/f7987547-c98a-411f-ad41-79c457db67d8/UTJwTlpqc3/c7ad355b-38cf-4421-969b-2ebf03d662bc.png

poush commented 7 years ago

Done able to create Event with this image,

{
  "data": {
    "relationships": {
      "organizers": {
        "links": {
          "self": "/v1/events/22/relationships/organizers",
          "related": "/v1/users"
        }
      },
      "ticket-tags": {
        "links": {
          "self": "/v1/events/22/relationships/ticket-tags",
          "related": "/v1/events/22/ticket-tags"
        }
      },
      "speakers-call": {
        "links": {
          "self": "/v1/events/22/relationships/speakers-call",
          "related": "/v1/events/22/speakers-call"
        }
      },
      "tax": {
        "links": {
          "self": "/v1/events/22/relationships/tax",
          "related": "/v1/events/22/tax"
        }
      },
      "coorganizers": {
        "links": {
          "self": "/v1/events/22/relationships/coorganizers",
          "related": "/v1/users"
        }
      },
      "session-types": {
        "links": {
          "self": "/v1/events/22/relationships/session-types",
          "related": "/v1/events/22/session-types"
        }
      },
      "microlocations": {
        "links": {
          "self": "/v1/events/22/relationships/microlocations",
          "related": "/v1/events/22/microlocations"
        }
      },
      "orders": {
        "links": {
          "self": "/v1/events/22/relationships/orders",
          "related": "/v1/events/22/orders"
        }
      },
      "speakers": {
        "links": {
          "self": "/v1/events/22/relationships/speakers",
          "related": "/v1/events/22/speakers"
        }
      },
      "event-copyright": {
        "links": {
          "self": "/v1/events/22/relationships/event-copyright",
          "related": "/v1/events/22/event-copyright"
        }
      },
      "attendees": {
        "links": {
          "self": "/v1/events/22/relationships/attendees",
          "related": "/v1/events/22/attendees"
        }
      },
      "custom-forms": {
        "links": {
          "self": "/v1/events/22/relationships/custom-forms",
          "related": "/v1/events/22/custom-forms"
        }
      },
      "track-organizers": {
        "links": {
          "self": "/v1/events/22/relationships/track-organizers",
          "related": "/v1/users"
        }
      },
      "event-type": {
        "links": {
          "self": "/v1/events/22/relationships/event-type",
          "related": "/v1/events/22/event-type"
        }
      },
      "discount-codes": {
        "links": {
          "self": "/v1/events/22/relationships/discount-codes",
          "related": "/v1/events/22/discount-codes"
        }
      },
      "event-sub-topic": {
        "links": {
          "self": "/v1/events/22/relationships/event-sub-topic",
          "related": "/v1/events/22/event-sub-topic"
        }
      },
      "sessions": {
        "links": {
          "self": "/v1/events/22/relationships/sessions",
          "related": "/v1/events/22/sessions"
        }
      },
      "event-topic": {
        "links": {
          "self": "/v1/events/22/relationships/event-topic",
          "related": "/v1/events/22/event-topic"
        }
      },
      "registrars": {
        "links": {
          "self": "/v1/events/22/relationships/registrars",
          "related": "/v1/users"
        }
      },
      "sponsors": {
        "links": {
          "self": "/v1/events/22/relationships/sponsors",
          "related": "/v1/events/22/sponsors"
        }
      },
      "tracks": {
        "links": {
          "self": "/v1/events/22/relationships/tracks",
          "related": "/v1/events/22/tracks"
        }
      },
      "access-codes": {
        "links": {
          "self": "/v1/events/22/relationships/access-codes",
          "related": "/v1/events/22/access-codes"
        }
      },
      "role-invites": {
        "links": {
          "self": "/v1/events/22/relationships/role-invites",
          "related": "/v1/events/22/role-invites"
        }
      },
      "tickets": {
        "links": {
          "self": "/v1/events/22/relationships/tickets",
          "related": "/v1/events/22/tickets"
        }
      },
      "social-links": {
        "links": {
          "self": "/v1/events/22/relationships/social-links",
          "related": "/v1/events/22/social-links"
        }
      },
      "moderators": {
        "links": {
          "self": "/v1/events/22/relationships/moderators",
          "related": "/v1/users"
        }
      },
      "event-invoices": {
        "links": {
          "self": "/v1/events/22/relationships/event-invoices",
          "related": "/v1/events/22/event-invoices"
        }
      }
    },
    "attributes": {
      "payment-country": null,
      "paypal-email": null,
      "code-of-conduct": "",
      "schedule-published-on": null,
      "payment-currency": null,
      "organizer-description": "",
      "is-map-shown": false,
      "original-image-url": "http://localhost/static/media/events/22/original/YjRJVVR5Z2/68ab8252-2c95-4f98-8992-c8bb0d309ac7.jpg",
      "onsite-details": null,
      "organizer-name": null,
      "longitude": null,
      "large-image-url": "http://localhost/static/media/events/22/large/UkZ0Vzdidm/8169625e-5ebf-4c76-afa8-25144c90fdc3.jpg",
      "timezone": "Asia/Kolkata",
      "can-pay-onsite": false,
      "deleted-at": null,
      "ticket-url": null,
      "can-pay-by-paypal": false,
      "location-name": null,
      "is-sponsors-enabled": false,
      "is-sessions-speakers-enabled": false,
      "privacy": "public",
      "has-organizer-info": false,
      "state": "Draft",
      "latitude": null,
      "starts-at": "2002-05-30T04:00:10+00:00",
      "searchable-location-name": null,
      "is-ticketing-enabled": true,
      "can-pay-by-cheque": false,
      "description": "",
      "pentabarf-url": null,
      "xcal-url": null,
      "logo-url": null,
      "can-pay-by-bank": false,
      "is-tax-enabled": false,
      "icon-image-url": "http://localhost/static/media/events/22/icon/WW9JM3k2Ym/42e319f4-9707-48ab-bd8a-51845995b395.jpg",
      "ical-url": null,
      "name": "New Event",
      "bank-details": null,
      "thumbnail-image-url": "http://localhost/static/media/events/22/thumbnail/TkkyMjlXWj/4ed4fb87-84e1-4553-a18c-b0ad138f9e4a.jpg",
      "created-at": "2017-08-19T10:29:26.159338+00:00",
      "can-pay-by-stripe": false,
      "cheque-details": null,
      "external-event-url": null,
      "identifier": "240646f6",
      "ends-at": "2022-05-30T04:00:10+00:00"
    },
    "type": "event",
    "id": "22",
    "links": {
      "self": "/v1/events/22"
    }
  },
  "jsonapi": {
    "version": "1.0"
  },
  "links": {
    "self": "/v1/events/22"
  }
}
poush commented 7 years ago

@SaptakS Try to reproduce it. I'm not able to do reproduce it here.

SaptakS commented 7 years ago

@poush you won't be able to reproduce in your local system if you are using management command. If you use nginx in your server with same configuration as in heroku, then you might. This is mainly being caused because of timeout to download the image from the url. Please implement it using celery. @fossasia/open-event-server-devs please look into this.

ba11b0y commented 6 years ago

@poush @shubham-padia For the given heroku logs, the problem was I guess fixed in #4496 . Please check. Thanks.

mariobehling commented 6 years ago

Seems to be fixed. Please reopen and comment if anything is left.