Staticman: 500 error "INVALID_VERSION"

Created on 17 Apr 2019  路  7Comments  路  Source: eduardoboucas/staticman

POSTing to this: https://api.staticman.net/v3/entry/github/rskupnik/rskupnik.github.io/master/comments

With the following data:

options[slug] | hello-world
fields[name] | Myz
fields[email] | [email protected]
fields[message] | Hello+comments

Config:

comments:
    allowedFields: ["name", "email", "message"]
    filename: "{@id}"
    branch: "master"
    path: "_data/comments/{options.postId}"
    filename: "{@id}"

I'm receiving a 500 error with the following json: {"success":false,"errorCode":"INVALID_VERSION"}

help wanted question

Most helpful comment

@mitchtossi In my case the INVALID_VERSION error comes if you try to use an endpoint not supported by the version. E.g., ${host}/v2/entry/github/travisdowns/blog-test/master/comments. You have to remove the github because the "service" path component isn't supported by the v2 endpoint.

All 7 comments

Try version 2 of the api instead. Also, checkout #291.

If you want to see what API version is supported for each endpoint, then you can look at the Staticman initializeRoutes function. As you can see in the code copied below, the particular route that you are trying to call only supports API version 2.

  this.server.post(
    '/v:version/entry/:username/:repository/:branch/:property',
    this.bruteforce.prevent,
    this.requireApiVersion([2]),
    this.requireParams(['fields']),
    this.controllers.process
  )

That is apparent from the call to requireApiVersion this.requireApiVersion([2]).

If the version that you supply to the endpoint does not match one of the versions being required in the route initialization, then an error with error code INVALID_VERSION is raised.

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

I hope that the trouble you have run into doesn't discourage you from using Staticman. Staticman respects your users' privacy, so it is worth the effort that it takes to set it up.

If you want to see what API version is supported for each endpoint, then you can look at the Staticman initializeRoutes function. As you can see in the code copied below, the particular route that you are trying to call only supports API version 2.

 this.server.post(
   '/v:version/entry/:username/:repository/:branch/:property',
   this.bruteforce.prevent,
   this.requireApiVersion([2]),
   this.requireParams(['fields']),
   this.controllers.process
 )

@BloggerBust However, underneath the code that you've cited, there comes a support for v3.

https://github.com/eduardoboucas/staticman/blob/2be29f73fa0688e02770b9f118288b6e0e617b01/server.js#L74-L81

If the version that you supply to the endpoint does not match one of the versions being required in the route initialization, then an error with error code INVALID_VERSION is raised.

Also, note that the reported error code is 500 instead of 400 in the code block.

I hope that the trouble you have run into doesn't discourage you from using Staticman. Staticman respects your users' privacy, so it is worth the effort that it takes to set it up.

I'm going to end my comment with this message also, but for a different "trouble": Staticman's spam problem. From these spam that the Staticman App has made in a user's repo, the GitHub App is surely working. Nobody wants them though.

I'm still encountering the same problem (INVALID_VERSION) and I really don't get how to fix it...

@mitchossi did you try using the v2 endpoint? I'm not entirely sure about the state of the public instances.

@mitchtossi In my case the INVALID_VERSION error comes if you try to use an endpoint not supported by the version. E.g., ${host}/v2/entry/github/travisdowns/blog-test/master/comments. You have to remove the github because the "service" path component isn't supported by the v2 endpoint.

The response by Travis appears to have addressed the problem. Closing, but feel free to ask any follow up questions here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

clairity picture clairity  路  12Comments

joeczar picture joeczar  路  3Comments

zburgermeiszter picture zburgermeiszter  路  8Comments

jkbecker picture jkbecker  路  5Comments

eduardoboucas picture eduardoboucas  路  11Comments