question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Making POST request on class or Collection instance returns Internal Server Error

See original GitHub issue

I’m submitting a

  • bug report.
  • feature request.

Current Behaviour:

When making a POST or DELETE request to the class instance with a new request body gives an error. But it does update the instance with new values.

Expected Behaviour:

It should not give the error.

Steps to reproduce:

  1. Start hydrus server (master revision) with this APIDoc: https://gist.github.com/priyanshunayan/0dc02d65e1f036b9a45919b5342d00a4
  2. Create a new class instance by making PUT to /Movie endpoint with request body:
{
    "@type": "Movie",
    "movie_name": "Godfather",
    "movie_director": "F.F Coppola"
}
  1. Now make a POST request to this class instance at /Movie/object-id with updated request body
  2. It should return the following error:

Traceback (most recent call last):
  File "/Users/priyanshunayan/Developer/creating_api_doc/venv/lib/python3.8/site-packages/flask/app.py", line 2464, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Users/priyanshunayan/Developer/creating_api_doc/venv/lib/python3.8/site-packages/flask/app.py", line 2450, in wsgi_app
    response = self.handle_exception(e)
  File "/Users/priyanshunayan/Developer/creating_api_doc/venv/lib/python3.8/site-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/Users/priyanshunayan/Developer/creating_api_doc/venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/Users/priyanshunayan/Developer/creating_api_doc/venv/lib/python3.8/site-packages/flask/app.py", line 1867, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/priyanshunayan/Developer/creating_api_doc/venv/lib/python3.8/site-packages/flask/_compat.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/Users/priyanshunayan/Developer/creating_api_doc/venv/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/priyanshunayan/Developer/creating_api_doc/venv/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/priyanshunayan/Developer/creating_api_doc/venv/lib/python3.8/site-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/Users/priyanshunayan/Developer/creating_api_doc/venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/Users/priyanshunayan/Developer/creating_api_doc/venv/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/priyanshunayan/Developer/creating_api_doc/venv/lib/python3.8/site-packages/flask/_compat.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/Users/priyanshunayan/Developer/creating_api_doc/venv/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/priyanshunayan/Developer/creating_api_doc/venv/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/priyanshunayan/Developer/creating_api_doc/venv/lib/python3.8/site-packages/flask_restful/__init__.py", line 468, in wrapper
    resp = resource(*args, **kwargs)
  File "/Users/priyanshunayan/Developer/creating_api_doc/venv/lib/python3.8/site-packages/flask/views.py", line 89, in view
    return self.dispatch_request(*args, **kwargs)
  File "/Users/priyanshunayan/Developer/creating_api_doc/venv/lib/python3.8/site-packages/flask_restful/__init__.py", line 583, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/Users/priyanshunayan/Developer/creating_api_doc/venv/lib/python3.8/site-packages/hydrus/auth.py", line 89, in wrapper
    return f(*args, **kwargs)
  File "/Users/priyanshunayan/Developer/creating_api_doc/venv/lib/python3.8/site-packages/hydrus/resources.py", line 123, in post
    return items_post_check_support(id_, object_, class_path, path, is_collection)
  File "/Users/priyanshunayan/Developer/creating_api_doc/venv/lib/python3.8/site-packages/hydrus/itemhelpers.py", line 84, in items_post_check_support
    send_sync_update(socketio=socketio, new_job_id=new_job_id,
  File "/Users/priyanshunayan/Developer/creating_api_doc/venv/lib/python3.8/site-packages/hydrus/helpers.py", line 367, in send_sync_update
    socketio.emit('update', data, namespace="/sync")
  File "/Users/priyanshunayan/Developer/creating_api_doc/venv/lib/python3.8/site-packages/flask_socketio/__init__.py", line 416, in emit
    self.server.emit(event, *args, namespace=namespace, room=room,
AttributeError: 'NoneType' object has no attribute 'emit'

-->

Snapshot:

image

Environment:

  • python version - 3.8.2
  • pip version - pip 20.1.1
  • OS details - macOS Big Sur(11.1)

Do you want to work on this issue?

no

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
farazkhanfk7commented, Jan 28, 2021

Try using create_socket function that takes an instance of app and session like socketio = create_socket(app, session) See if this could solve the issue : https://gist.github.com/farazkhanfk7/d2a932c85f952739671a9d4fda60c5da This should work.

1reaction
Mec-iScommented, Jan 25, 2021

thanks for the bug report. just a note to avoid overflow of information: there is no need to paste the entire HTML code, the Python stacktrace and the screenshot are enough.

It seems that the helper is calling from the wrong object when it does self.server.emit(). self.server is not defined. @sameshl

Read more comments on GitHub >

github_iconTop Results From Across the Web

500 Internal error from HTTP POST request - Stack Overflow
500 Internal Server Error is a server error, ie. the problem is on the server side, not client side. You need to check...
Read more >
How to Fix a 500 Internal Server Error on Your WordPress Site
The 500 Internal Server Error status code occurs when the server encounters an error that prevents it from fulfilling the request.
Read more >
HTTP 500 Internal Server Error: What It Means & How to Fix It
This error is a server response to stop sending requests because of overloaded resources. This code might show up if your site needs...
Read more >
500 Internal Server Error - HTTP - MDN Web Docs - Mozilla
This error response is a generic "catch-all" response. Usually, this indicates the server cannot find a better 5xx error code to response.
Read more >
500 Internal Server Error | Apigee Edge
The HTTP status code 500 is a generic error response. It means that the server encountered an unexpected condition that prevented it from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found