eduardoboucas / staticman.net

💪 Staticman website
https://staticman.net
4 stars 11 forks source link

[BUG] Error in the instructions for legacy GitHub bot authorisation #15

Open VincentTam opened 3 years ago

VincentTam commented 3 years ago

Description

In step 3 of option 2 (GitHub bot) of stage 1 of the quickstart guide, https://github.com/eduardoboucas/staticman.net/blob/d1174fed6813a79f5ab002e01b3a77cfa47cea60/docs/getting-started.md#option-2-authenticate-to-github-using-a-personal-access-token-on-a-bot, a sample link is shown.

  1. Return to this step once your Staticman instance is running and send a GET request to {STATICMAN_BASE_URL}/v3/connect/{GIT_PROVIDER_USERNAME}/{REPO} For example: https://staticmaninstance.herokuapp.com/v3/connect/eduardoboucas/staticman.net

I tried GET https://{myAppName}.herokuapp.com/v3/connect/eduardoboucas/staticman.net

Expected behavior

The following step suggested OK!. Of course, I'm expecting an error here since I don't own this repo.

Error received

{"success":false,"errorCode":"INVALID_VERSION"}

:warning: The errorCode is unexpected here.

Screenshot:

Screenshot from 2021-02-12 15-37-45

Analysis

The errorCode INVALID_VERSION is thrown due to one of the following reasons.

      if (!versionMatch) {
        return res.status(400).send({
          success: false,
          errorCode: 'INVALID_VERSION'
        })
      }

https://github.com/eduardoboucas/staticman/blob/5d7ed7708775e3d4864382cca88d2d73ff875864/server.js#L122-L127

      if (!serviceMatch) {
        return res.status(400).send({
          success: false,
          errorCode: 'INVALID_SERVICE'
        })
      }

https://github.com/eduardoboucas/staticman/blob/5d7ed7708775e3d4864382cca88d2d73ff875864/server.js#L137-L142

That should be a version mismatch due to the absence of 3 in the code for the route /connect.

    this.server.get(
      '/v:version/connect/:username/:repository',
      this.bruteforce.prevent,
      this.requireApiVersion([1, 2]),
      this.controllers.connect
    )

https://github.com/eduardoboucas/staticman/blob/5d7ed7708775e3d4864382cca88d2d73ff875864/server.js#L49-L54

alexwaibel commented 3 years ago

Good catch. This issue is resolved in the dev branch, so similar to #14 we need to promote dev to master.