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

Clicking on resources tab gives 502 error sporadically #770

Closed
linzjax opened this issue Oct 4, 2016 · 14 comments
Closed

Clicking on resources tab gives 502 error sporadically #770

linzjax opened this issue Oct 4, 2016 · 14 comments

Comments

@linzjax
Copy link
Contributor

linzjax commented Oct 4, 2016

Steps to reproduce the error

Go to a project you don't have permission to view resources on (this is the one I was looking at)
Click between the resource tab and the overview tab until you get a 502 error.

Actual behavior

Sporadic 502 errors.

Expected behavior

I should see an empty table every time.

@ian-ross
Copy link
Contributor

ian-ross commented Oct 4, 2016

Nasty. I wonder what that could be. 502s normally come from nginx or UWSGI. Maybe one for @amplifi?

@linzjax
Copy link
Contributor Author

linzjax commented Oct 4, 2016

error log print out:

Subject[Django] ERROR (EXTERNAL IP): Internal Server Error: /organizations/olivers-org/projects/olivers-project/resources/
DateToday at 9:33 AM
Internal Server Error: /organizations/olivers-org/projects/olivers-project/resources/

UnicodeEncodeError at /organizations/olivers-org/projects/olivers-project/resources/
'ascii' codec can't encode character '\xea' in position 1207: ordinal not in range(128)

...
Traceback: 

File "/opt/cadasta/env/lib/python3.5/site-packages/django/template/base.py" in _resolve_lookup
883. current = current[bit]

File "/opt/cadasta/env/lib/python3.5/site-packages/django/template/context.py" in __getitem__
77. raise KeyError(key)

During handling of the above exception ('unarchive_url'), another exception occurred:

File "/opt/cadasta/env/lib/python3.5/site-packages/django/template/base.py" in _resolve_lookup
889. if isinstance(current, BaseContext) and getattr(type(current), bit):

During handling of the above exception (type object 'RequestContext' has no attribute 'unarchive_url'), another exception occurred:

File "/opt/cadasta/env/lib/python3.5/site-packages/django/template/base.py" in _resolve_lookup
898. current = current[int(bit)]

During handling of the above exception (invalid literal for int() with base 10: 'unarchive_url'), another exception occurred:

File "/opt/cadasta/env/lib/python3.5/site-packages/django/template/base.py" in _resolve_lookup
905. (bit, current)) # missing attribute

@ian-ross
Copy link
Contributor

ian-ross commented Oct 4, 2016

Oh no. It's the Unicode logging error, back to haunt us like the ghost of Jacob Marley.

@amplifi
Copy link
Contributor

amplifi commented Oct 5, 2016

Confirmed; this error is bubbling up from Django. Everything server-side is still set to UTF-8.

@linzjax
Copy link
Contributor Author

linzjax commented Oct 5, 2016

It might also be this, but since I can't reproduce the error I'm not sure. It's missing the unarchive_url definition that happens in this template

@ian-ross
Copy link
Contributor

ian-ross commented Oct 5, 2016

Hmmm. Should the form_modal block in project_list.html really have that modal in it at all? @seav added that -- is it needed there, Eugene? The resource unarchiving modal doesn't seem to be referenced anywhere within that template.

(None of this explains why we're getting these sporadic logging errors, but it might explain the increase in their frequency again.)

@linzjax
Copy link
Contributor Author

linzjax commented Oct 5, 2016

So, it needs to be there in order for this button to work.
screen shot 2016-10-05 at 3 40 47 pm

@ian-ross
Copy link
Contributor

ian-ross commented Oct 5, 2016

Hmmm. Eugene wrote some pretty ugly JS to do this, which is why it's been really hard to track down what's going on. The unarchive URL is set up from a HTML data attribute in the JS at the bottom of the resources/table.html template. When the resources/project_list.html template is rendered, including the resources/modal_unarchive.html template, unarchive_url isn't assigned, so I would have thought that the templating engine would complain at that point because it can't find unarchive_url in the template context. That's what seems to be happening on the production sites sometimes, but not in the development VM, and not 100% of the time. Any ideas, @seav?

@ian-ross
Copy link
Contributor

ian-ross commented Oct 5, 2016

@seav When I said "pretty ugly JS", that's not a pejorative judgment against you, by the way. The JS more or less always ends up being ugly in these cases, because you have lots of little bits of it lying around in different places, and it's hard to track down what's going on.

@seav
Copy link
Contributor

seav commented Oct 5, 2016

Hmmm... I've never encountered any errors in the dev VM because of the lack of the unarchive_url variable, but if it helps to eliminate a possible cause for the 502 error, we can add a dummy unarchive_url to the include call:

{% include 'resources/modal_unarchive.html' with unarchive_url="#" %}

@ian-ross
Copy link
Contributor

ian-ross commented Oct 6, 2016

Let's try that and see what happens. I'll make a tiny PR for it, and we can merge it and ask @amplifi to deploy to staging today or tomorrow so we can see if it makes a difference. Since we don't have any other leads for why this is happening, trying this is as good an idea as any, I think.

ian-ross pushed a commit that referenced this issue Oct 6, 2016
ian-ross pushed a commit that referenced this issue Oct 6, 2016
seav pushed a commit that referenced this issue Oct 6, 2016
@seav
Copy link
Contributor

seav commented Oct 7, 2016

So far I haven't encountered any 502 errors while browsing the staging site, which should already have PR #797. Can anybody else confirm?

@linzjax
Copy link
Contributor Author

linzjax commented Oct 7, 2016

I can't make any pop up. Are org admins now allowed to see deleted resources?

If they are it might be worth adding the same Active/Archived filter to the resources table. Definitely not urgent though.

@dpalomino
Copy link

Hi,

I haven't seen any other 502 errors either. I think we could close this issue and if needed open a new one for the active/archive resources (low prio)...

This is what I see for deleted resources (as a org admin):

screen shot 2016-10-10 at 12 53 05

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants