Skip to content
This repository was archived by the owner on Aug 27, 2020. It is now read-only.
This repository was archived by the owner on Aug 27, 2020. It is now read-only.

"runtime error: index out of range" when scraping an invalid torrent #77

@aidanharris

Description

@aidanharris

This bug is reproducible as follows:

curl http://127.0.0.1:1337/scrape/invalidTorrent

EDIT: The fix for this is probably to do whatever happens when making an invalid request to /torrent/invalidTorrent and output the following:

{"message":"Torrent not found."}

SECOND EDIT: I'm new to programming in Golang so I'm not sure how efficient this is but I managed to solve this issue by adding the following to the beggining of of the apiScrape function:

defer func() {
        if s := recover(); s != nil {
            r.JSON(404, map[string]interface{}{"message": "Torrent not found."})
            return
        }
    }()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions