Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[server] 500 Error with wrong parent #765

Closed
AlekseyLobanov opened this issue Jan 29, 2022 · 5 comments · Fixed by #885
Closed

[server] 500 Error with wrong parent #765

AlekseyLobanov opened this issue Jan 29, 2022 · 5 comments · Fixed by #885
Labels
bug needs-contributor Someone needs to implement this. Help wanted! server (Python) server code
Milestone

Comments

@AlekseyLobanov
Copy link

Hello.
I use latest stable version with Docker setup.
I found that internal sqlite table does not use any constraints on parent column of table comments which may be a problem in two cases.

  1. DB is corrupted and one of the parents is not valid.
  2. Someone trying to add comment with invalid parent.

I tried second case with curl and got 500 Error on client and stacktrace below on server

2022-01-29 22:57:29,824 ERROR: POST /new
Traceback (most recent call last):
  File "/isso/lib/python3.8/site-packages/isso-0.12.5-py3.8.egg/isso/__init__.py", line 147, in dispatch
    response = handler(request.environ, request, **values)
  File "/isso/lib/python3.8/site-packages/isso-0.12.5-py3.8.egg/isso/views/comments.py", line 88, in dec
    return func(self, env, req, *args, **kwargs)
  File "/isso/lib/python3.8/site-packages/isso-0.12.5-py3.8.egg/isso/views/__init__.py", line 45, in dec
    return func(cls, env, req, *args, **kwargs)
  File "/isso/lib/python3.8/site-packages/isso-0.12.5-py3.8.egg/isso/views/comments.py", line 307, in new
    rv = self.comments.add(uri, data)
  File "/isso/lib/python3.8/site-packages/isso-0.12.5-py3.8.egg/isso/db/comments.py", line 57, in add
    if ref.get("parent") is not None:
AttributeError: 'NoneType' object has no attribute 'get'

Steps to reproduce:

  1. Start Docker instance of isso (on http://127.0.0.1:8080/ for example)
  2. POST request http://127.0.0.1:8080/new?uri=%2Fbase.html with valid comment and wrong parent. I used "Copy as cURL" button on Firefox Web Tools and replaced null with some invalid id (42 for example)
@ix5 ix5 added bug needs-contributor Someone needs to implement this. Help wanted! server (Python) server code labels Jan 29, 2022
@ix5
Copy link
Member

ix5 commented Jan 29, 2022

@AlekseyLobanov thank you for your report.
Would you mind working on a fix and submitting a PR?

@ix5 ix5 added this to the 0.12.5 milestone Feb 13, 2022
@ix5
Copy link
Member

ix5 commented Feb 15, 2022

Related: #531

@ix5
Copy link
Member

ix5 commented Apr 23, 2022

@AlekseyLobanov would you like to work on a PR?

@ix5 ix5 changed the title 500 Error with wrong parent [server] 500 Error with wrong parent Apr 23, 2022
@ix5
Copy link
Member

ix5 commented Apr 23, 2022

Copying over from #531, quoting @budui

I am porting isso from Python to Go. While testing I noticed that if I specify a wrong parent(existed but different thread) for the new comment, the new comment will be added successfully but can't be retrievaled with uri.

Maybe we need to check whether the tid of new comment and parent's tid are consistent
https://github.com/posativ/isso/blob/6092881bb205c999a8f7f086dd5d20f686d641ea/isso/db/comments.py#L49-L52

@ix5
Copy link
Member

ix5 commented May 25, 2022

Tracked in #885

@ix5 ix5 closed this as completed May 25, 2022
ix5 added a commit to ix5/isso that referenced this issue May 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs-contributor Someone needs to implement this. Help wanted! server (Python) server code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants