applegrew / django-select2

This is a Django integration for Select2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issues when certain special characters appear in the field_id

scnerd opened this issue · comments

Describe the bug
Occassionally, my select2 stops working. I get requests like the following:

myapp_1     | Not Found: /select2/fields/auto.json
myapp_1     | [pid: 26|app: 0|req: 1/13] xxx.xxx.xxx.xxx () {46 vars in 2545 bytes} [Wed Feb  5 19:20:54 2020] GET /select2/fields/auto.json?term=myterm&field_id=MTM5NjM3ODc4OTQyNDk2%3A1izQ4o%3AdsSPO9__2hwS7wzv1_VU2sEqUBA => generated 1855 bytes in 227 msecs (HTTP/2.0 404) 5 headers in 149 bytes (1 switches on core 0)

I've seen similar behavior when the field_id includes sequences like --. I think these characters are the issue, because I can reboot the server and cache (I'm using a dockerized Redis, so I just rm the container), refresh the page, and, if the new field ID is cleaner, it usually works. Of course, since these field ID's are random and cycle every once in a while, it makes the whole system highly unreliable.

I'm using the widget within a form rendered by crispy forms, so I'm not sure if that might be breaking something. Regardless, if the field ID could be limited to a simple characterset (say, only alphanumeric), that would probably prevent this issue. I must be doing something wrong if no one else is running into this; is there a configuration or something I can provide to help figure this out? I'm running in Django 2.x, Python 3.7 or 3.8, and again, I'm rendering forms using crispy forms.

Thanks.

Hi @scnerd thanks for reaching out. Interesting issue. Right of the bat, this sounds like an encoding issue or something, but I'm flying pretty blind. Would you mind sharing a bit more information about your setup. Besides crispy, that is. What WSGI server are you using, what cache, what proxy, what server setup?
I hope we can figure this out, best Joe

Sorry about the lack of info, wasn't sure what would be helpful...

WSGI server: uWSGI, reverse-proxied by nginx directly via uwsgi_pass

Cache: Redis, using the most recent docker pull (5.x I think)

Everything's running in Docker.

OOC, does this endpoint report 404 if the cache key wasn't found?

@scnerd yes, it does return a 404, but it does that on all errors, however the message varies. Can you check your browsers network log, to tell me the 404 message?

I didn't think to nab this... it was intermittent, so next time I get this error, I'll report back.

This repo has moved, please address your issue at https://github.com/codingjoe/django-select2 Thanks!