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

Update octokit/rest API calls to 16.24.3 #288

Conversation

BloggerBust-bot
Copy link

Depends on: PR #285

The octokit/rest git createReference and deleteReference functions have changed to createRef and deleteRef. Without this update staticman will respond with errorCode GITHUB_CREATING_PR when trying to process a PR.

@VincentTam
Copy link
Contributor

Depends on: PR #285

I'm just curious about your PR. Is this PR specific to Staticman v2? Have you tested its compatibility with v3?

@BloggerBust-bot
Copy link
Author

Depends on: PR #285

I'm just curious about your PR. Is this PR specific to Staticman v2? Have you tested its compatibility with v3?

I have only tested with v2.

@VincentTam
Copy link
Contributor

Depends on: PR #285

I'm just curious about your PR. Is this PR specific to Staticman v2? Have you tested its compatibility with v3?

I have only tested with v2.

As I'm using Staticman with GitLab, the v3 URL scheme is needed. However, I didn't (and won't) implement #243, so there's no need for the rollback. As a result, to test this PR, I've cherry-picked bb1a1a8 on top of 9ce2c48. This PR does solve the problem described in #299 (comment), but I get the following deprecation messages. Besides, I can't get webhooks working. I received "service timeout". The actual payload JSON is too large to be posted here.

@BloggerBust-bot Have you seen such messages? Anyways thanks for great fix.

> staticman@3.0.0 prestart /app
> if [ ! -d node_modules ]; then npm install; fi


> staticman@3.0.0 start /app
> node index.js

Staticman API running on port undefined
]: State changed from starting to up
Deprecation: [@octokit/rest] new Octokit({timeout}) is deprecated. Use {request: {timeout}} instead. See https://github.com/octokit/request.js#request
at parseOptions (/app/node_modules/@octokit/rest/lib/parse-client-options.js:43:34)
at Octokit (/app/node_modules/@octokit/rest/lib/constructor.js:20:31)
at new GitHub (/app/lib/GitHub.js:16:16)
at Object.module.exports.create (/app/lib/GitServiceFactory.js:11:14)
at new Staticman (/app/lib/Staticman.js:28:25)
at module.exports (/app/controllers/process.js:124:21)
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
at next (/app/node_modules/express/lib/router/route.js:137:13)
at /app/server.js:199:12
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
at next (/app/node_modules/express/lib/router/route.js:137:13)
at /app/server.js:181:12
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
at next (/app/node_modules/express/lib/router/route.js:137:13)
at /app/server.js:156:12
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
at next (/app/node_modules/express/lib/router/route.js:137:13)
at /app/server.js:141:12
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
at next (/app/node_modules/express/lib/router/route.js:137:13)
at module.exports.<anonymous> (/app/node_modules/express-brute/index.js:142:36)
at module.exports.MemoryStore.set (/app/node_modules/express-brute/lib/MemoryStore.js:28:35) {
name: 'Deprecation'
}
Deprecation: [@octokit/rest] new Octokit({headers}) is deprecated. Use {userAgent, previews} instead. See https://github.com/octokit/request.js#request
at parseOptions (/app/node_modules/@octokit/rest/lib/parse-client-options.js:53:34)
at Octokit (/app/node_modules/@octokit/rest/lib/constructor.js:20:31)
at new GitHub (/app/lib/GitHub.js:16:16)
at Object.module.exports.create (/app/lib/GitServiceFactory.js:11:14)
at new Staticman (/app/lib/Staticman.js:28:25)
at module.exports (/app/controllers/process.js:124:21)
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
at next (/app/node_modules/express/lib/router/route.js:137:13)
at /app/server.js:199:12
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
at next (/app/node_modules/express/lib/router/route.js:137:13)
at /app/server.js:181:12
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
at next (/app/node_modules/express/lib/router/route.js:137:13)
at /app/server.js:156:12
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
at next (/app/node_modules/express/lib/router/route.js:137:13)
at /app/server.js:141:12
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
at next (/app/node_modules/express/lib/router/route.js:137:13)
at module.exports.<anonymous> (/app/node_modules/express-brute/index.js:142:36)
at module.exports.MemoryStore.set (/app/node_modules/express-brute/lib/MemoryStore.js:28:35) {
name: 'Deprecation'
}
Deprecation: [@octokit/rest] octokit.authenticate() is deprecated. Use "auth" constructor option instead.
at authenticate (/app/node_modules/@octokit/rest/plugins/authentication-deprecated/authenticate.js:9:44)
at new GitHub (/app/lib/GitHub.js:31:16)
at Object.module.exports.create (/app/lib/GitServiceFactory.js:11:14)
at new Staticman (/app/lib/Staticman.js:28:25)
at module.exports (/app/controllers/process.js:124:21)
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
at next (/app/node_modules/express/lib/router/route.js:137:13)
at /app/server.js:199:12
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
at next (/app/node_modules/express/lib/router/route.js:137:13)
at /app/server.js:181:12
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
at next (/app/node_modules/express/lib/router/route.js:137:13)
at /app/server.js:156:12
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
at next (/app/node_modules/express/lib/router/route.js:137:13)
at /app/server.js:141:12
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
at next (/app/node_modules/express/lib/router/route.js:137:13)
at module.exports.<anonymous> (/app/node_modules/express-brute/index.js:142:36)
at module.exports.MemoryStore.set (/app/node_modules/express-brute/lib/MemoryStore.js:28:35)
at module.exports.<anonymous> (/app/node_modules/express-brute/index.js:127:17) {
name: 'Deprecation'
}
Deprecation: [@octokit/rest] octokit.repos.createFile() has been renamed to octokit.repos.createOrUpdateFile() (2019-06-07)
at Object.deprecatedEndpointMethod [as createFile] (/app/node_modules/@octokit/rest/plugins/register-endpoints/register-endpoints.js:50:28)
at GitHub._commitFile (/app/lib/GitHub.js:52:27)
at GitHub.writeFile (/app/lib/GitService.js:86:17)
at GitHub.writeFile (/app/lib/GitHub.js:64:18)
at /app/lib/GitService.js:92:24
at processTicksAndRejections (internal/process/task_queues.js:85:5) {
name: 'Deprecation'
}

Copy link
Contributor

@VincentTam VincentTam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace all instances of createFile by createOrUpdateFile due to the last Deprecation message above.

@BloggerBust-bot
Copy link
Author

@BloggerBust-bot Have you seen such messages? Anyways thanks for great fix.

Thank you. I may have seen a message similar to the service timeout that you describe. I ran into quite a number of issues with octokit and found that the easiest way to trouble shoot them was to test it directly in a node repl. I used code similar to what I have pasted below to work through these sorts of problems:

@octokit
/rest')

var api = githubApi({
debug: true,
baseUrl: 'https://api.github.com',
headers: {
'user-agent': 'Staticman agent'
},
timeout: 5000
})

api.authenticate({
type: 'token',
token: '<MY-TOKEN>'
});

api.repos.listInvitationsForAuthenticatedUser({}).then(({data}) => {
console.log('made it inside the then statement');

}).catch((error) => {
console.error('Error listing inventations for authenticated user.', error);
});```

@VincentTam what version of octokit are you using? I only tested with version 16.24.3.

@VincentTam
Copy link
Contributor

I dunno Node.JS. I deployed it to Heroku. Here's the first few lines of git grep octokit. Hope that answers your question.

lib/GitHub.js:const githubApi = require('@octokit/rest')
package-lock.json:    "@octokit/rest": {
package-lock.json:      "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-15.9.4.tgz",
package.json:    "@octokit/rest": "^16.3.2",

@BloggerBust-bot
Copy link
Author

Replace all instances of createFile by createOrUpdateFile due to the last Deprecation message above.

I can look into this over the weekend. Right now I have an urgent need to complete a tag system project that I recently started. It might take me another two days to complete it.

@BloggerBust-bot
Copy link
Author

BloggerBust-bot commented Jul 4, 2019

lib/GitHub.js:const githubApi = require('@octokit/rest')
package-lock.json:    "@octokit/rest": {
package-lock.json:      "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-15.9.4.tgz",
package.json:    "@octokit/rest": "^16.3.2",

Your package.json says that you are using the latest version 16.x.x of the octokit rest api. Change that to "16.24.3" without a caret "^". If that solves your problem then we know it is a change in the latest API (16.28.x) since 16.24.3. Hopefully updating our usage of the API so that we are no longer calling deprecated methods will solve the issue.

Learning how to use a node repl will really speed up trouble shooting this API.

@BloggerBust-bot
Copy link
Author

lib/GitHub.js:const githubApi = require('@octokit/rest')
package-lock.json:    "@octokit/rest": {
package-lock.json:      "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-15.9.4.tgz",
package.json:    "@octokit/rest": "^16.3.2",

Your package.json says that you are using the latest version 16.x.x of the octokit rest api. Change that to "16.24.3" without a caret "^". If that solves your problem then we know it is a change in the latest API (16.28.x) since 16.24.3. Hopefully updating our usage of the API so that we are no longer calling deprecated methods will solve the issue.

Learning how to use a node repl will really speed up trouble shooting this API.

Actually, I just noticed that package-lock.json is resolving https://registry.npmjs.org/@octokit/rest/-/rest-15.9.4.tgz. This article explains package-lock.json and might help you trouble shoot version management issues.

@VincentTam
Copy link
Contributor

Replace all instances of createFile by createOrUpdateFile due to the last Deprecation message above.

I can look into this over the weekend. Right now I have an urgent need to complete a tag system project that I recently started. It might take me another two days to complete it.

Thanks for reply. I've run into a similar situation. Lemme come back to this a few weeks later.

@BloggerBust
Copy link

BloggerBust commented Jul 8, 2019

Hi info-bot,

I was thinking if I merged this into my fork I could connect like so:

https://mystaticinstance.heroku.com/v2/connect/orgname/reponame

but that just hangs after the merge, before it rejected the request..

You will need to look into the logs to see what is happening on the server. You want to watch what the octokit/rest library is doing. That is most likely the point of failure.

Are you seeing the "service timeout" error described by @VincentTam? I only tested this for version 16.24.3. You could try removing the caret symbol "^" in front of the octokit/rest version in package.json and set the version specifically to 16.24.3. package-lock.json may also need to be updated. Read comments above. Once I have time (soonish) I will help VincentTam sort it out if he has not already done so.

something changed but idk why the app even needs access to the repo at all if I'm using moderated... anyone can make a pull-request.

The app creates the branch right in your repo so that it can merge it by itself if you choose to turn off moderation. For Blogger Bust, I currently have moderation turned on because of spam, but once I have a solution in place to deal with that I would like to turn off moderation.

Note, that the most efficient way to trouble shoot octokit/rest is in a node repl.

@VincentTam
Copy link
Contributor

I currently have moderation turned on because of spam, but once I have a solution in place to deal with that I would like to turn off moderation.

@BloggerBust I wonder if #195 can help.

@alexwaibel
Copy link
Collaborator

This has been resolved in #319 so I'll be closing this PR. Your contribution was helpful when making my own similar changes. Thank you for your contribution!

@alexwaibel alexwaibel closed this Dec 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants