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

share_file_with_link OCS error 996 #259

Open
CrohnEngineer opened this issue Feb 10, 2021 · 9 comments
Open

share_file_with_link OCS error 996 #259

CrohnEngineer opened this issue Feb 10, 2021 · 9 comments

Comments

@CrohnEngineer
Copy link

Hey everybody,

following the usage example, I'm writing a simple script to put a file on OwnCloud and then share it with a link.
Everything goes fine, until I call oc.share_file_with_link(remote_file_path), when the error stack trace reports a OSC error 996 (which, if I'm not mistaken, corresponds to a server error).
Can anybody suggest me what is happening here? Has anyone else encountered this issue before?
I anticipate that I use pyocclient 0.6, but I do not manage the OC server directly, so I might miss some information on that side.
Thank you in advance!

@landryb
Copy link

landryb commented Mar 12, 2021

Not sure 100% related to your issue since you didnt post code, there seems to be a regression from commit 5aa5b93 which inconditionally checks that the server replied with a 'name' attribute, which doesnt seem to be the case with nextcloud 21.

here's a simple reproducer:

import owncloud
import sys

oc = owncloud.Client('https://fqdn', debug=True)
oc.login('ncadmin','xxx')

try:
    print("share: {}".format(oc.share_file_with_link('orgs/COM_TEST', password='pass')))
except owncloud.HTTPResponseError as e:
    print("Exception: {}".format(e))
    sys.exit()

oc.logout()

which gives:

OCS request: POST https://fqdn/ocs/v1.php/apps/files_sharing/api/v1/shares {'data': {'shareType': 3, 'path': '/orgs/COM_TEST', 'password': 'pass'}, 'headers': {'OCS-APIREQUEST': 'true'}}
Traceback (most recent call last):
  File "datamisc/tests/test_share_file_with_link_pyocc06.py", line 16, in <module>
    print("share: {}".format(oc.share_file_with_link('orgs/COM_TEST', password='pass')))
  File "/home/landry/scratch/venv/lib/python3.7/site-packages/owncloud/owncloud.py", line 910, in share_file_with_link
    'name': data_el.find('name').text
AttributeError: 'NoneType' object has no attribute 'text'

sadly, it seems to be the same if you pass a name argument to the method, so i dunno against which server it was tested/developed (owncloud ? nextcloud ?) nor which version but that feels broken. @PVince81 ?

looking at the doc (not sure its the right/latest one ?) name isnt mentioned on https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-share-api.html#create-a-new-share but it is on https://doc.owncloud.com/server/developer_manual/core/apis/ocs-share-api.html#create-a-new-share so i'd say this is only working with owncloud ?

testing via curl, there's no name attribute in the returned XML for nextcloud 21.

$curl -u ncadmin -H "OCS-APIREQUEST: true" -X POST -dpath=/orgs/COM_TEST -dpassword=pass -dshareType=3 https://fqdn/ocs/v1.php/apps/files_sharing/api/v1/shares
Enter host password for user 'ncadmin':
<?xml version="1.0"?>
<ocs>
 <meta>
  <status>ok</status>
  <statuscode>100</statuscode>
  <message>OK</message>
  <totalitems></totalitems>
  <itemsperpage></itemsperpage>
 </meta>
 <data>
  <id>41</id>
  <share_type>3</share_type>
  <uid_owner>ncadmin</uid_owner>
  <displayname_owner>ncadmin</displayname_owner>
  <permissions>17</permissions>
  <can_edit>1</can_edit>
  <can_delete>1</can_delete>
  <stime>1615554587</stime>
  <parent/>
  <expiration/>
  <token>cbiNfrBs49idf6T</token>
  <uid_file_owner>ncadmin</uid_file_owner>
  <note></note>
  <label></label>
  <displayname_file_owner>ncadmin</displayname_file_owner>
  <path>/orgs/COM_TEST</path>
  <item_type>folder</item_type>
  <mimetype>httpd/unix-directory</mimetype>
  <has_preview></has_preview>
  <storage_id>local::/data/web/nextcloud/data/</storage_id>
  <storage>2</storage>
  <item_source>6475</item_source>
  <file_source>6475</file_source>
  <file_parent>2174</file_parent>
  <file_target>/COM_TEST</file_target>
  <share_with>xxxxx</share_with>
  <share_with_displayname>(Lien partagé)</share_with_displayname>
  <password>xxx</password>
  <send_password_by_talk></send_password_by_talk>
  <url>https://fqdn/s/cbiNfrBs49idf6T</url>
  <mail_send>1</mail_send>
  <hide_download>0</hide_download>
 </data>
</ocs>

@CrohnEngineer
Copy link
Author

Hey @landryb ,

Not sure 100% related to your issue since you didnt post code,

sorry about this, but as I wrote in my first post I simply used the code provided in the README.md.
So, just using this code snippet:

import owncloud

oc = owncloud.Client('http://domain.tld/owncloud')

oc.login('user', 'password')

oc.mkdir('testdir')

oc.put_file('testdir/remotefile.txt', 'localfile.txt')

link_info = oc.share_file_with_link('testdir/remotefile.txt')

print "Here is your link: " + link_info.get_link() 

gives me the aforementioned OSCError 996.
Using the code snippet you provided gives me the same error, with the same error stack trace (see below):

Traceback (most recent call last):
  File "owncloud_file_testing.py", line 8, in <module>
    print("share: {}".format(oc.share_file_with_link('zip_folders.py', password='pass')))
  File "/nas/home/ecannas/miniconda3/lib/python3.7/site-packages/owncloud/owncloud.py", line 902, in share_file_with_link
    self._check_ocs_status(tree)
  File "/nas/home/ecannas/miniconda3/lib/python3.7/site-packages/owncloud/owncloud.py", line 1738, in _check_ocs_status
    raise OCSResponseError(r)
owncloud.owncloud.OCSResponseError: OCS error: 996

Therefore, it seems to me that my issue is unrelated to the one you are mentioning. Any thoughts about it?
Anyway, thanks for passing by and sorry for the delay in answering you.
Bests,

Edoardo

@landryb
Copy link

landryb commented Apr 6, 2021

well, if you're using pyocclient against owncloud, no i dont think that's the same issue :)

@CrohnEngineer
Copy link
Author

Good to know!

@luffah
Copy link

luffah commented Apr 15, 2021

Similar bugs #218, #259. #263 (with a simple fix proposal - a mere workaround)

@dogganos
Copy link

Any news on this?
Same problem after upgrading owncloud to:
./occ status

  • installed: true
  • first_install_version: 10.0.10.4
  • version: 10.12.1.3
  • versionstring: 10.12.1
  • edition: Community

I increased verbosity level on owncloud server to debug and while I get logs while the login is happening and while the upload is happening, I get nothing in the logs when the server sends this 996 error, which in the owncloud documentation is supposed to be 'internal server error'.

@lathass-123
Copy link

@CrohnEngineer , Any solution for the error oc.share_file_with_link() raising 996 error?
Can any one help here?

@CrohnEngineer
Copy link
Author

Hey @lathass-123 ,

I found a turnaround by using the same code but disabling the SSL credentials check; however, I would not advise doing that since it is not safe from a security point of view.
To be honest, since no answer came from this thread, and I don't like sharing my credentials in the clear over the Web, I stopped using the library years ago :)
I hope you have better luck than me!

@lathass-123
Copy link

Hey CrohnEngineer,

Thank you for the update. I will check what i can do.

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

No branches or pull requests

5 participants