Describe the bug
Endpoint PATCH: /v1/sessions/{session_id} is not working in Android app.
Logs
D/OkHttp: Authorization: JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NTk5MzIyMDAsImlhdCI6MTU1OTg0NTgwMCwibmJmIjoxNTU5ODQ1ODAwLCJpZGVudGl0eSI6NzYyMn0.vrImL-LPXamU9xG8QZ0yWjPW3NFG9nCzkWH3LZ_bIqA
{"data":{"type":"session","id":"5328","attributes":{"short-abstract":"This session will answer questions of what is FOSS, what's so good about it and how to join in the open-source community.","comments":"","long-abstract":null,"level":null,"signup-url":null,"ends-at":null,"language":"","title":"Introduction to Open Source Community","starts-at":null,"slides-url":null,"average-rating":null,"submitted-at":null,"deleted-at":null,"subtitle":null,"created-at":null,"state":null,"last-modified-at":null,"video-url":null,"audio-url":null,"session-type":{"id":709,"name":"Discussion","length":"00:30","deleted-at":null}},"relationships":{"event":{"data":{"type":"event","id":"827"}},"session-type":{"data":{"type":"session-type","id":"709"}},"track":{"data":{"type":"track","id":"1247"}}}}}
--> END PATCH (787-byte body)
D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000
D/OpenGLRenderer: HWUI Binary is enabled
D/OkHttp: <-- 500 https://api.eventyay.com/v1/sessions/5328 (250ms)
D/OkHttp: date: Thu, 06 Jun 2019 18:50:22 GMT
content-type: application/vnd.api+json
content-length: 140
set-cookie: __cfduid=d99b6172394fac620341b892c2f0db5911559847022; expires=Fri, 05-Jun-20 18:50:22 GMT; path=/; domain=.eventyay.com; HttpOnly
access-control-allow-origin: *
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
server: cloudflare
cf-ray: 4e2c92529f2a732f-AMS
D/OkHttp: {"errors": [{"detail": "Unknown error", "source": {"pointer": ""}, "status": 500, "title": "Unknown error"}], "jsonapi": {"version": "1.0"}}
<-- END HTTP (140-byte body)
W/libEGL: EGLNativeWindowType 0x7d441f7010 disconnect failed
E/SpeakersCallProposalViewModel$editProposal: Fail on updating session 5328
retrofit2.adapter.rxjava2.HttpException: HTTP 500
at retrofit2.adapter.rxjava2.BodyObservable$BodyObserver.onNext(BodyObservable.java:54)
at retrofit2.adapter.rxjava2.BodyObservable$BodyObserver.onNext(BodyObservable.java:37)
at retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(CallExecuteObservable.java:44)
at io.reactivex.Observable.subscribe(Observable.java:12267)
at retrofit2.adapter.rxjava2.BodyObservable.subscribeActual(BodyObservable.java:34)
at io.reactivex.Observable.subscribe(Observable.java:12267)
at io.reactivex.internal.operators.observable.ObservableSingleSingle.subscribeActual(ObservableSingleSingle.java:35)
at io.reactivex.Single.subscribe(Single.java:3603)
at io.reactivex.internal.operators.single.SingleDoOnSuccess.subscribeActual(SingleDoOnSuccess.java:35)
at io.reactivex.Single.subscribe(Single.java:3603)
at io.reactivex.internal.operators.single.SingleSubscribeOn$SubscribeOnObserver.run(SingleSubscribeOn.java:89)
at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:578)
at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66)
at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:784)
Additional context
Discussion on: https://github.com/fossasia/open-event-android/pull/1886
@anhanh11001 tested it via postman, seems to be working fine on local
@uds5501 Please try the exact payload mentioned in the issue
@uds5501 Have you figured it out what was the problems from the server and can you show me how did you test to make it work? I'm having trouble both on creating/updating sessions and need some advices
"session-type":{"id":709,"name":"Discussion","length":"00:30","deleted-at":null}
This seems to be the problem @anhanh11001 . My local server can't process this. Try restructuring it as:
"session-type": {
"id":"709",
"data": {
"attributes": {
"name": "Discussion",
"length": "00:30",
"deleted-at": null
}
},
"type" : "session-type"
}
I hope this solves the error
@anhanh11001 @uds5501 Closing the following .
Not to be closed until verified working
@uds5501 I still have problem updating session here. Please take a look, I think I've followed the example in the API document
D/OkHttp: --> PATCH https://api.eventyay.com/v1/sessions/5336
Content-Type: application/vnd.api+json
Content-Length: 233
Authorization: JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NjA1OTU3ODAsImlhdCI6MTU2MDUwOTM4MCwibmJmIjoxNTYwNTA5MzgwLCJpZGVudGl0eSI6ODEyMn0.oMucbKuWncBrD-dsjbQZeJY9LuI9oFuQZnd7WjiaiJU
{"data":{"type":"session","id":"5336","attributes":{"title":"New Session","language":"","short-abstract":"","comments":""},"relationships":{"event":{"data":{"type":"event","id":"839"}},"track":{"data":{"type":"track","id":"1260"}}}}}
--> END PATCH (233-byte body)
D/OkHttp: <-- 500 https://api.eventyay.com/v1/sessions/5336 (255ms)
date: Fri, 14 Jun 2019 11:16:59 GMT
content-type: application/vnd.api+json
content-length: 140
set-cookie: __cfduid=dacae68288537d283db70b90465b5cf971560511019; expires=Sat, 13-Jun-20 11:16:59 GMT; path=/; domain=.eventyay.com; HttpOnly
access-control-allow-origin: *
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
server: cloudflare
cf-ray: 4e6be5302e672bec-AMS
D/OkHttp: {"errors": [{"detail": "Unknown error", "source": {"pointer": ""}, "status": 500, "title": "Unknown error"}], "jsonapi": {"version": "1.0"}}
D/OkHttp: <-- END HTTP (140-byte body)
W/libEGL: EGLNativeWindowType 0x7b7aec0010 disconnect failed
E/SpeakersCallProposalViewModel$editProposal: Fail on updating session $5336
retrofit2.adapter.rxjava2.HttpException: HTTP 500
at retrofit2.adapter.rxjava2.BodyObservable$BodyObserver.onNext(BodyObservable.java:54)
at retrofit2.adapter.rxjava2.BodyObservable$BodyObserver.onNext(BodyObservable.java:37)
at retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(CallExecuteObservable.java:47)
at io.reactivex.Observable.subscribe(Observable.java:12267)
at retrofit2.adapter.rxjava2.BodyObservable.subscribeActual(BodyObservable.java:34)
at io.reactivex.Observable.subscribe(Observable.java:12267)
at io.reactivex.internal.operators.observable.ObservableSingleSingle.subscribeActual(ObservableSingleSingle.java:35)
at io.reactivex.Single.subscribe(Single.java:3603)
at io.reactivex.internal.operators.single.SingleDoOnSuccess.subscribeActual(SingleDoOnSuccess.java:35)
at io.reactivex.Single.subscribe(Single.java:3603)
at io.reactivex.internal.operators.single.SingleSubscribeOn$SubscribeOnObserver.run(SingleSubscribeOn.java:89)
at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:578)
at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66)
at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:784)
@anhanh11001 Can you instead post the logs of the server here? Once it's a 500 without a reason, client-side logs don't give enough info.
@CosmicCoder96 He doesn't have access to server logs, that's why we need this fixed ASAP https://github.com/fossasia/open-event-server/issues/4903
Please try again and post the response
@anhanh11001 Please post the response
And do it on the debug server
Sorry for not responding, I'll do it now and send the response
@anhanh11001 please post the response so that we can move forward if this issue doesn't persist now.
It's still failling. Here is my request:
```
{"data":{"type":"session","attributes":{"title":"vvg","language":"","short-abstract":"","comments":""},"relationships":{"event":{"data":{"type":"event","id":"23"}},"track":{"data":{"type":"track","id":"7"}}}}}
````
Here is the response and the log, it is pretty long, please take a look
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.6/site-packages/sentry_sdk/integrations/flask.py", line 68, in sentry_patched_wsgi_app
environ, start_response
File "/app/.heroku/python/lib/python3.6/site-packages/sentry_sdk/integrations/wsgi.py", line 95, in __call__
reraise(*_capture_exception(hub))
File "/app/.heroku/python/lib/python3.6/site-packages/sentry_sdk/_compat.py", line 53, in reraise
raise value
File "/app/.heroku/python/lib/python3.6/site-packages/sentry_sdk/integrations/wsgi.py", line 93, in __call__
rv = self.app(environ, start_response)
File "/app/.heroku/python/lib/python3.6/site-packages/sentry_sdk/integrations/flask.py", line 67, in <lambda>
return SentryWsgiMiddleware(lambda *a, **kw: old_app(self, *a, **kw))(
File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 2463, in __call__
return self.wsgi_app(environ, start_response)
File "/app/app/__init__.py", line 72, in __call__
return self.app(environ, start_response)
File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 2449, in wsgi_app
response = self.handle_exception(e)
File "/app/.heroku/python/lib/python3.6/site-packages/flask_cors/extension.py", line 161, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "/app/.heroku/python/lib/python3.6/site-packages/flask_cors/extension.py", line 161, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1866, in handle_exception
reraise(exc_type, exc_value, tb)
File "/app/.heroku/python/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/app/.heroku/python/lib/python3.6/site-packages/flask_cors/extension.py", line 161, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "/app/.heroku/python/lib/python3.6/site-packages/flask_cors/extension.py", line 161, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/app/.heroku/python/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1949, in full_dispatch_request
File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/app/.heroku/src/flask-rest-jsonapi/flask_rest_jsonapi/api.py", line 133, in decorated
File "/app/app/api/helpers/permission_manager.py", line 480, in permission_manager
return permissions[args[0]](view, view_args, view_kwargs, *args, **kwargs)
File "/app/app/api/helpers/permission_manager.py", line 325, in create_event
return view(*view_args, **view_kwargs)
File "/app/.heroku/src/flask-rest-jsonapi/flask_rest_jsonapi/decorators.py", line 32, in wrapper
File "/app/.heroku/python/lib/python3.6/site-packages/flask/views.py", line 89, in view
return self.dispatch_request(*args, **kwargs)
File "/app/.heroku/src/flask-rest-jsonapi/flask_rest_jsonapi/resource.py", line 68, in dispatch_request
response = method(*args, **kwargs)
File "/app/.heroku/src/flask-rest-jsonapi/flask_rest_jsonapi/decorators.py", line 56, in wrapper
data, errors = schema.load(json_data)
File "/app/.heroku/python/lib/python3.6/site-packages/marshmallow/schema.py", line 578, in load
result, errors = self._do_load(data, many, partial=partial, postprocess=True)
File "/app/.heroku/python/lib/python3.6/site-packages/marshmallow_jsonapi/schema.py", line 244, in _do_load
result = super(Schema, self)._do_load(data, many, **kwargs)
File "/app/.heroku/python/lib/python3.6/site-packages/marshmallow/schema.py", line 673, in _do_load
field_errors=field_errors)
File "/app/.heroku/python/lib/python3.6/site-packages/marshmallow/schema.py", line 925, in _invoke_validators
pass_original=pass_original)
res = validator_func(output, original_data)
File "/app/app/api/schema/sessions.py", line 48, in validate_date
if data['starts_at'] and data['ends_at']:
KeyError: 'starts_at'
@shreyanshdwivedi does this mean that I have to specify the time of the session as well? If so then I think you can close this issue now, as I have figured out the problem and I'll fix in the client side?
But it is kinda weird that if a speaker needs to include the specific date/time when sending a proposal. They aren't even sure if they are accepted,
No this issue shouldn't be closed. Server should throw proper error if a required key is missing. Not a 500
Also, we just want the traceback bit from the logs
@anhanh11001 I think you missed id in the request data. Please include id and try.
I used your request data and added id. It worked
{
"data": {
"attributes": {
"title":"vvg","language":"","short-abstract":"","comments":""
},
"type": "session",
"id": "11"
}
}
My request data ^^
Yes, my bad, PATH request was working fine, request I mentioned above was POST request to create a proposal but I also figured it out the way to make it works now as well, so there is no problem in the client-side now.
Most helpful comment
@anhanh11001 I think you missed
idin the request data. Please include id and try.I used your request data and added
id. It workedMy request data ^^