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

incompatible with DSM 7: errors with "Invalid parameter" #166

Closed
Cesco117 opened this issue Dec 28, 2020 · 10 comments
Closed

incompatible with DSM 7: errors with "Invalid parameter" #166

Cesco117 opened this issue Dec 28, 2020 · 10 comments
Labels

Comments

@Cesco117
Copy link

Cesco117 commented Dec 28, 2020

current status (maintainer edit)

Synology confirmed they are changing how this extension will have to talk to Download Station in DSM 7, but they have declined to specify how or when DSM 7 will leave beta. Until Synology provides more information and/or releases DSM 7, I cannot make appropriate changes and the extension will continue to be incompatible.

original issue follows

Description

I updated my DS215j on DSM 7 Beta, and since this moment, some features, like the "right clik => Download with Synology Download Manager" doesn't work anymore.
Yet, the "magnet link copy paste" on the extension still work.
I know that DSM is still in beta, but it means that it may not work in the future, and If I knew that the extension didn't fully work, I would have not updated DSM.
Thanks a lot

Steps to Reproduce the Issue

  1. Right click on a download torrent link
  2. Click on "Download with Synology Download Manager"

Failure Logs

Redacted extension state: {
  "settings": {
    "connection": {
      "protocol": "http",
      "hostname": true,
      "port": true,
      "username": true,
      "password": true
    },
    "visibleTasks": {
      "downloading": true,
      "uploading": true,
      "completed": true,
      "errored": true,
      "other": true
    },
    "taskSortType": "name-asc",
    "notifications": {
      "enableFeedbackNotifications": true,
      "enableCompletionNotifications": false,
      "completionPollingInterval": 60
    },
    "shouldHandleDownloadLinks": true,
    "badgeDisplayType": "filtered"
  },
  "tasks": 6,
  "taskFetchFailureReason": null,
  "tasksLastInitiatedFetchTimestamp": 1609180566190,
  "tasksLastCompletedFetchTimestamp": 1609180568400,
  "lastSevereError": "(omitted for brevity)",
  "stateVersion": 5
}

error while trying to fetch metadata file type for download url

Error: 'timeout of 10000ms exceeded'
Error stack trace: parcelRequire<.bIiH</module.exports@moz-extension://bfc54761-4b82-8346-9a88-c52de4fa64e0/dist/background/index.js:226:87
parcelRequire<.KRuG</module.exports/</p.ontimeout@moz-extension://bfc54761-4b82-8346-9a88-c52de4fa64e0/dist/background/index.js:236:1080

Versions

Extension version: 0.9.0

Browser version: 84.0.1

DSM version: DSM 7.0-41222

@seansfkelley
Copy link
Owner

Thanks for the bug report! It looks like the root cause is actually the site you're trying to download from, though admittedly the extension doesn't handle this case very well. I gather this from the logs, specifically,

error while trying to fetch metadata file type for download url

and

Error: 'timeout of 10000ms exceeded'

so it looks like the particular download you're trying isn't working properly (the server could be loaded, your connection could be spotty, or the server might intentionally not respond to these types of requests).

From this, it seems likely that your observed behavior -- that it works when you copy the link in manually, rather than using right-click -- is caused by random chance, such as server load.

Do you have other downloads you could try to see if there's a pattern? If there's no pattern, I'm going to chalk this up to random chance combined with poor error handling, improvements to which are tracked by #64.

@Cesco117
Copy link
Author

Hi Sean,
Whaou, I didn't expect such a quick reply!

When it didn't work, nothing happened on the extension (no error message) but a click and download torrent file was ok (so the server were ok).

And to be clear, the link manually copied didn't work too, I was speaking about magnet link rather than http download links.

So to be sure what is happening, i will try again to download with the "right click" and will let you know.

Thanks again for the amazing work 👍

@seansfkelley
Copy link
Owner

You got good timing and caught me while I was already around!

So here's what I currently understand:

  • Downloading the .torrent file via an HTTP URL through the browser onto your computer works fine, so the server seems to be working.
  • Right-click and "Download with DownloadStation" for that same link doesn't work.
  • Using the + button in the extension popup to manually add a magnet link does not work.
  • Right-click and "Download with DownloadStation" on a magnet link also does not work.

Is that correct?

@Rhilip
Copy link

Rhilip commented Feb 15, 2021

I think add a torrent link from popup page is also broken.
with the following step:

  1. Add a DownloadStation Server from DSM7-beta demo in the extension.
  2. copy a torrent file link into the popup page for add task, like: https://nyaa.si/download/xxxxxx.torrent, it is open and without auth require.
  3. Add I saw the Invalid parameter notice.

the requests from network:
(and it connect with demo server from https://demo.synology.cn/en-global/dsm

POST /webapi/DownloadStation/task.cgi HTTP/1.1
Host: c135.dsm7demo.synology.com:5001
Connection: keep-alive
Content-Length: 100501
Accept: application/json, text/plain, */*
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36 Edg/88.0.705.68
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryFQx43TDOiSITuJDA
Origin: chrome-extension://iaijiochiiocodhamehbpmdlobhgghgi
Sec-Fetch-Site: none
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6
Cookie: did=Gr5YL58FfqapY55UgjetdM-_FWq5zz5PTT6ZEiY8FfhX3eJVgm7zDShJjH4no6AVA7EazNAk8sQWXySLnzZtHw; _CrPoSt=aHR0cHM6Ly9jMTM1LmRzbTdkZW1vLnN5bm9sb2d5LmNvbTo1MDAxLw%3D%3D; io=cer4uYtw-JA6o77FAAAA

------WebKitFormBoundaryFQx43TDOiSITuJDA
Content-Disposition: form-data; name="api"
SYNO.DownloadStation.Task
------WebKitFormBoundaryFQx43TDOiSITuJDA
Content-Disposition: form-data; name="version"

1
------WebKitFormBoundaryFQx43TDOiSITuJDA
Content-Disposition: form-data; name="method"

create
------WebKitFormBoundaryFQx43TDOiSITuJDA
Content-Disposition: form-data; name="sid"

cyUmxPo1o1H4wE-339V7TeMyMRky3CdabH30A16xEngoxwE3sQdtIfGUwZSjC5aB3E3ZX3hGCIlw3ru5SSkshM
------WebKitFormBoundaryFQx43TDOiSITuJDA
Content-Disposition: form-data; name="_sid"

cyUmxPo1o1H4wE-339V7TeMyMRky3CdabH30A16xEngoxwE3sQdtIfGUwZSjC5aB3E3ZX3hGCIlw3ru5SSkshM
------WebKitFormBoundaryFQx43TDOiSITuJDA
Content-Disposition: form-data; name="file"; filename="13385_1613385339.torrent"
Content-Type: application/x-bittorrent

xxxxxxxxxxxxxxxxxxxx

and the response is:

{"error":{"code":101},"success":false}

@seansfkelley
Copy link
Owner

seansfkelley commented Feb 15, 2021

Thank you so much @Rhilip! I wasn't aware they had demo DSMs available. That allowed me to do some debugging and I have determined that this is almost certainly a bug on Synology's end. I have filed a bug with their support system and am waiting for a response.

The rest of this comment is just details for those interested and my own record-keeping. I'll update this ticket when I know more.

To reproduce without access to DSM 7, I went to https://demo.synology.com/en-global/dsm and spun up a new machine. It automatically logs you in as an admin with an unknown password, so I created a new user account with Download Station permissions.

I confirmed that the new user works with the extension:

  • login works
  • task list loading works
  • adding magnet links and non-.torrent HTTP(S) links works

What does not work is uploading a .torrent file. I used torrent files from https://cdimage.debian.org/debian-cd/current/amd64/bt-cd/ as testing until I realized that the content of the file appeared to be irrelevant.

I wrote the following script to mimic the requests the extension uses. It requires a host, username and password to function.

#!/bin/bash

# please note that this script was written on macOS, so it might not be 100%
# portable as written (in particular, echo -n may not work on other systems)
# this script also requires `curl` and `jq`

set -euxo pipefail

HOST='???'
USERNAME='???'
PASSWORD='???'

# get sid token
SID=$(curl "https://$HOST:5001/webapi/auth.cgi?account=$USERNAME&api=SYNO.API.Auth&format=sid&method=login&passwd=$PASSWORD&session=DownloadStation&version=4" | jq -r .data.sid)

# dump the request into a file as it's the easiest way to build up a complex curl form in pieces
request_file=$(mktemp)
echo -n $'-----------------------------116640802018974929061761783305' >> "$request_file"
echo -n $'\r\nContent-Disposition: form-data; name="api"\r\n\r\nSYNO.DownloadStation.Task\r\n-----------------------------116640802018974929061761783305' >> "$request_file"
echo -n $'\r\nContent-Disposition: form-data; name="version"\r\n\r\n1\r\n-----------------------------116640802018974929061761783305' >> "$request_file"
echo -n $'\r\nContent-Disposition: form-data; name="method"\r\n\r\ncreate\r\n-----------------------------116640802018974929061761783305' >> "$request_file"
echo -n $'\r\nContent-Disposition: form-data; name="_sid"\r\n\r\n' >> "$request_file"
echo -n "$SID" >> "$request_file"
echo -n $'\r\n-----------------------------116640802018974929061761783305' >> "$request_file"
echo -n $'\r\nContent-Disposition: form-data; name="file"; filename="somefilename.torrent"\r\nContent-Type: application/x-bittorrent\r\n\r\n' >> "$request_file"
echo -n $'torrent file content does not actually matter for this bug\r\n' >> "$request_file"
echo -n $'-----------------------------116640802018974929061761783305\r\n' >> "$request_file"

# try to add the task
curl "https://$HOST:5001/webapi/DownloadStation/task.cgi" -H 'Content-Type: multipart/form-data; boundary=---------------------------116640802018974929061761783305' --data-binary "@$request_file"

On DSM 6, a task is added and I get the response {"success":true}. (Ignoring the fact that the torrent file itself is invalid.)

On DSM 7, no task is added and I get the response {"error":{"code":101},"success":false} which means "invalid parameter".

I did some guesswork based on past experience and other projects' issues with DSM 7 I found on the internet, but no changes resolved the issue. Things like: changing the version parameter (both for login and task-create); switching between _sid and sid parameter names, using real .torrent files...

@seansfkelley seansfkelley added this to the next milestone Feb 15, 2021
@seansfkelley
Copy link
Owner

I received a response from Synology support:

The old Download Station API will not compatible with DSM 7.0 Download Station version.

Unfortunately, there is no announced release date at the moment.

Until they update their documentation, my hands are tied. I'll be updating the descriptions of the extensions and pinning this issue until I know more.

@seansfkelley seansfkelley pinned this issue Feb 22, 2021
@seansfkelley seansfkelley changed the title Some features stopped working on DSM 7 beta incompatible with DSM 7: errors with "Invalid parameter" Mar 18, 2021
@seansfkelley
Copy link
Owner

This is likely the same root cause as #177, given that Synology's response also mentioned DSM 7.0 support.

@seansfkelley
Copy link
Owner

Hi @Cesco117 and @Rhilip, I just released a new version (0.10.0) that I think should fix this issue but I'm unable to test effectively without updating my Synology. Can you update your installation and verify if it does?

@Maudissure
Copy link

Hi, i wrote an issue probably related with the 0.10.0 update , i'm on DSM 7.0

@seansfkelley
Copy link
Owner

Alright, 0.10.1 should work with DSM 7 now. Synology silently broke the authentication API (again).

It's up for Firefox now. Chrome usually takes a couple days for approval.

@seansfkelley seansfkelley unpinned this issue Apr 28, 2021
@seansfkelley seansfkelley removed this from the next milestone Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants