6.3.6 Pro - api broken + User Feedback As I Go + Conclusion

2018-10-04 16:19:44,807 [ERROR] django.request:135 handle_uncaught_exception Internal Server Error: /api2/ping/
Traceback (most recent call last):
  File "/seafile/seafile-pro-server-6.3.6/seahub/thirdpart/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/seafile/seafile-pro-server-6.3.6/seahub/thirdpart/django/core/handlers/base.py", line 249, in _legacy_get_response
    response = self._get_response(request)
  File "/seafile/seafile-pro-server-6.3.6/seahub/thirdpart/django/core/handlers/base.py", line 217, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/seafile/seafile-pro-server-6.3.6/seahub/thirdpart/django/core/handlers/base.py", line 215, in _get_response
    response = response.render()
  File "/seafile/seafile-pro-server-6.3.6/seahub/thirdpart/django/template/response.py", line 107, in render
    self.content = self.rendered_content
  File "/seafile/seafile-pro-server-6.3.6/seahub/thirdpart/rest_framework/response.py", line 71, in rendered_content
    ret = renderer.render(self.data, media_type, context)
  File "/seafile/seafile-pro-server-6.3.6/seahub/thirdpart/rest_framework/renderers.py", line 676, in render
    ret = template.render(context)
  File "/seafile/seafile-pro-server-6.3.6/seahub/thirdpart/django/template/backends/django.py", line 64, in render
    context = make_context(context, request, autoescape=self.backend.engine.autoescape)
  File "/seafile/seafile-pro-server-6.3.6/seahub/thirdpart/django/template/context.py", line 287, in make_context
    raise TypeError('context must be a dict rather than %s.' % context.__class__.__name__)
TypeError: context must be a dict rather than RequestContext.

It’s an upgrade from 6.2.13 to 6.3.6

Uploaded and extracted the latest seafile to the server, ran upgrade script, seahub works,sync works, api gives this error.

Any suggestions? The api is mandatory for me…

I have to add, on first sight it seems the api does work with requests other than /ping.
I can request a login token for example. Ping error still remains…

Encountered another error: url: /api/v2.1/admin/devices/

2018-10-06 12:52:22,863 [ERROR] django.request:135 handle_uncaught_exception Internal Server Error: /api/v2.1/admin/devices/
Traceback (most recent call last):
  File "/seafile/seafile-pro-server-6.3.6/seahub/thirdpart/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/seafile/seafile-pro-server-6.3.6/seahub/thirdpart/django/core/handlers/base.py", line 249, in _legacy_get_response
    response = self._get_response(request)
  File "/seafile/seafile-pro-server-6.3.6/seahub/thirdpart/django/core/handlers/base.py", line 217, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/seafile/seafile-pro-server-6.3.6/seahub/thirdpart/django/core/handlers/base.py", line 215, in _get_response
    response = response.render()
  File "/seafile/seafile-pro-server-6.3.6/seahub/thirdpart/django/template/response.py", line 107, in render
    self.content = self.rendered_content
  File "/seafile/seafile-pro-server-6.3.6/seahub/thirdpart/rest_framework/response.py", line 71, in rendered_content
    ret = renderer.render(self.data, media_type, context)
  File "/seafile/seafile-pro-server-6.3.6/seahub/thirdpart/rest_framework/renderers.py", line 676, in render
    ret = template.render(context)
  File "/seafile/seafile-pro-server-6.3.6/seahub/thirdpart/django/template/backends/django.py", line 64, in render
    context = make_context(context, request, autoescape=self.backend.engine.autoescape)
  File "/seafile/seafile-pro-server-6.3.6/seahub/thirdpart/django/template/context.py", line 287, in make_context
    raise TypeError('context must be a dict rather than %s.' % context.__class__.__name__)
TypeError: context must be a dict rather than RequestContext.

In all honesty, it would be nice if the pro version would actually act like a pro version and just work :slight_smile:

In other news: there’s an undocumented option wipe_device when unlinking a device.

The above error only shows when visiting the URL in the browser with GET…

GET https://cloud.seafile.com/api2/events/

Getting file activity only seems to work for admin users, otherwise am getting ‘Forbidden’.

// I’m just gonna put everything I encounter working with the api in this thread

Edit: I got this to work now, my bad, events api is fine

Seafile Pro 6.3.3 updated Django to 1.11.11

@daniel.pan This seems to me like the seafile code was not updated accordingly, see e.g.: https://docs.djangoproject.com/en/2.1/releases/1.11/#django-template-backends-django-template-render-prohibits-non-dict-context

Have you already tried cleaning the cache?

not sure what this has to do with a programming error.shoeper.

  1. Another question, when listing a dir via the API, is there a way to limit its output via pages? It would become quite a mess if there are thousands of files in a directory wouldn’t it?

I’m talking about this: https://manual.seafile.com/develop/web_api_v2.1.html#list-directory-entries

  1. Is it possible to get the details of the library, amount of files in main folder for example?
    This function says / is not allowed as path, but how do you get this info from the the root folder then?
    https://manual.seafile.com/develop/web_api_v2.1.html#get-directory-detail

There is no “starred” field for the files when using:
List Directory Entries
GET https://cloud.seafile.com/api2/repos/{repo-id}/dir/

This should be implemented as it doesn’t make sense to request File Detail for every file the listing returns just to get the starred info

Not sure where oid comes from when trying to list a directory: made a github issue here:

When something from a previous version is cached it can lead to an exception, letting it look like a programming error.

Hi @MrMoronIV,

This error TypeError: context must be a dict rather than RequestContext. only occurs when you visit api through web page or using cUrl with html header like curl 'https://xxx/api2/ping/' -H 'Accept: text/html' which is not recommended.

The preferred method is curl 'https://xxx/api2/ping/' -H 'Accept: application/json' which works in 6.3.x

Anyway, we will update our code in next version which will fix those errors.

Many Thanks!

Thanks xiez!

I will continue posting my feedback in this thread when I encounter questions using the API, I hope there will come answers or implementations to my questions as well. E.g.: Is there a way to limit file listing output via pages…

cheers!

Currently there is no way to do pagination in list dir entries API, we will enhance this api in the future as well as whether file is starred.

You can open feature request in https://forum.seafile.com/c/feature if you want API enhancements.

Best regards

Manual error: https://manual.seafile.com/develop/web_api_v2.1.html#download-directory

It says: “Perform the following two steps to download directory”. Although it only shows one, then shows “Revert Directory” instructions, and then shows step 2

Seahub: Download Folder As Zip seems to be broken

API: zip creation and download works fine!

Question: is there a way to cancel the zip creation task? What if a user doesn’t want to wait for a huge zip, does it continue creating the zip anyway?

There’s a method missing to get the user permissions (read/write or read-only) of a certain folder.

Let’s say I’m user Bob, and I access a single read-only folder in a Read/Write shared library (Sonya is owner). How can Bob find out that the folder is read-only?

It would make sense to use the “Get Directory Detail” API, expecting it would return permission:r but it doesn’t do that.

The library detail returns permission but that’s global to the whole library, which can be different from a specific folder inside the same library.

Seahub returns user_perm r when opening the folder but it uses an internal url for an ajax call:
https://domain.com:8000/ajax/lib/d7478d33-fe1a-4018-86bd-708e9351384e/dir/?p=/read-only-folder&thumbnail_size=48&_=1539172930432

How can Bob find out he has read-only access using the API?

It would be nice to get a password:true/false parameter when listing the existing shared links:
GET https://cloud.seafile.com/api/v2.1/upload-links/

So we can check if the existing link has password enabled

It seems to be impossible to get information about a library being shared as public using the repo_id. There’s only a method to get all publicly shared libraries.

GET https://cloud.seafile.com/api2/repos/?type={type}
type
org, get public libraires.

A member (Bob) that is an Admin of a group where someone else (Alice) is the owner cannot leave that group.

2018-10-12 20:34:49,990 [ERROR] seahub.api2.endpoints.group_members:211 delete Group staff can not quit group

However, an admin (Bob) cannot remove admin privileges themselves, so an admin is basically stuck in a group unless the group owner (Alice) removes Admin privileges on Bob.

I think a user should always be able to leave a group, admin or not.