Skip to content

Fix tracker API error token not valid #419

@josecelano

Description

@josecelano

Relates to: #420

I've been checking the logs of the live demo. It's failing because the tracker token is not valid:

2023-12-26T11:00:35.187361844+00:00 [torrust_index::tracker::statistics_importer][INFO] Updating torrent 1 ...
2023-12-26T11:00:35.233911132+00:00 [torrust_index::tracker::service][ERROR] Failed to parse torrent info from tracker response. Body: Unhandled rejection: Err { reason: "token not valid" }
2023-12-26T11:00:35.242595113+00:00 [torrust_index::tracker::statistics_importer][ERROR] Error updating torrent tracker stats for torrent with id 1: TorrentNotFound

There are two issues:

  • Invalid token: Token not valid
  • Wrong logged error: TorrentNotFound

Invalid token

I think the problem is the token I'm using contains some special characters like %. In the API client:

    pub async fn get_torrent_info(&self, info_hash: &str) -> Result<Response, Error> {
        let request_url = format!("{}/torrent/{}?token={}", self.base_url, info_hash, self.connection_info.token);

        let client = reqwest::Client::new();

        client.get(request_url).send().await
    }

We are not URL-encoding the token. For example, given this the token 123g7#@agJtWFSgkdA5R$K22yeo$k6IhNq%T2$r the following URL doesn't work:

http://tracker.torrust-demo.com:1212/v1/stats?token=123g7#@agJtWFSgkdA5R$K22yeo$k6IhNq%T2$r

It should be:

http://tracker.torrust-demo.com:1212/v1/stats?token=123g7%23%40agJtWFSgkdA5R%24K22yeo%24k6IhNq%25T2%24r

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIncorrect Behavior

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions