Comments (22)
We should definitely catch that error instead of barfing, but could you let us know how you were authenticating?
from octokit.rb.
config[:login] = ...
config[:oauth_token] = ...
CLIENT = Octokit::Client.new(config)
REPO = "backlogs/redmine_backlogs"
....
CLIENT.replace_all_labels(REPO, issue.number, ['one', 'two'])
from octokit.rb.
But it throws a 404 error, not a 401 error. Maybe the server side of the GH API is broken? I've fetched the issue number using list_issues, and I've verified that it exists. And I'm the repo owner.
from octokit.rb.
Can you check the scope on that OAuth token? I suspect it might be public_repo and not repo scope.
from octokit.rb.
I apologize for having to ask this... but how do I so this? And how do I
generate a repo scope token?
from octokit.rb.
If you're using the Web flow for OAuth, simply declare what scopes you need as part of the initial request as outlined here.
If you're creating a stand alone non-web app for your own use and prefer not to use your username/pass on each request, you can create tokens via the Authorizations API.
from octokit.rb.
It's a stand-alone non-web app. Looking at that doc, should I be posting
{
"scopes": [ "backlogs/redmine_backlogs" ],
"note": "issue manager"
}
to get access to that repo? The docs are pretty scant.
from octokit.rb.
Try:
curl -i -u username -d '{"scopes": ["repo"], "note": "issue manager"}' https://api.github.com/authorizations
or you can use Octokit:
c = Octokit::Client.new :login => 'username', :password => 'password'
c.create_authorization :scopes => ['repo'], :note => 'issue manager'
from octokit.rb.
superb, thanks. The error is now
raise_octokit_error.rb:10:in `on_complete': PUT https://api.github.com/repos/backlogs/redmine_backlogs/issues/626/labels?access_token=blablabla: 400: Body should be a JSON Array (Octokit::BadRequest)
from octokit.rb.
Hrrm. It's working for me. Can you share your version of Ruby and Octokit?
from octokit.rb.
Octokit 1.7.0, ruby 1.8.7 and 1.9.3.
from octokit.rb.
Full trace:
raise_octokit_error.rb:10:in on_complete': PUT https://api.github.com/repos/backlogs/redmine_backlogs/issues/626/labels?access_token=blabla: 400: Body should be a JSON Array (Octokit::BadRequest) from /home/hnse/.rvm/gems/ruby-1.8.7-p358@redmine/gems/faraday-0.8.1/lib/faraday/response.rb:9:in
call'
from /home/hnse/.rvm/gems/ruby-1.8.7-p358@redmine/gems/faraday-0.8.1/lib/faraday/response.rb:63:in on_complete' from /home/hnse/.rvm/gems/ruby-1.8.7-p358@redmine/gems/faraday-0.8.1/lib/faraday/response.rb:8:in
call'
from /home/hnse/.rvm/gems/ruby-1.8.7-p358@redmine/gems/faraday_middleware-0.8.7/lib/faraday_middleware/request/encode_json.rb:21:in call' from /home/hnse/.rvm/gems/ruby-1.8.7-p358@redmine/gems/faraday-0.8.1/lib/faraday/connection.rb:226:in
run_request'
from /home/hnse/.rvm/gems/ruby-1.8.7-p358@redmine/gems/faraday-0.8.1/lib/faraday/connection.rb:99:in put' from /home/hnse/.rvm/gems/ruby-1.8.7-p358@redmine/gems/octokit-1.7.0/lib/octokit/request.rb:40:in
send'
from /home/hnse/.rvm/gems/ruby-1.8.7-p358@redmine/gems/octokit-1.7.0/lib/octokit/request.rb:40:in request' from /home/hnse/.rvm/gems/ruby-1.8.7-p358@redmine/gems/octokit-1.7.0/lib/octokit/request.rb:22:in
put'
from /home/hnse/.rvm/gems/ruby-1.8.7-p358@redmine/gems/octokit-1.7.0/lib/octokit/client/labels.rb:138:in `replace_all_labels'
from octokit.rb.
The labels you're sending in the labels
array, do they already exist on the repo? I was able to reproduce this if I used labels that did not already exist, but if I supplied labels that did exist it worked fine.
from octokit.rb.
Some of the labels did not exist. But from reading the docs, replace_all_labels ought to add what didn't exist, right?
from octokit.rb.
I assumed that if they didn't exist they would be created, but the API documentation doesn't specify. @pengwynn Thoughts on that?
from octokit.rb.
Current behavior is to 422 if the label doesn't exist. I'm looking to see if we can change that, but for now, we need to fail gracefully in Octokit.
from octokit.rb.
I've updated the GitHub API to allow creating labels on-the-fly which should fix this issue. Please reopen if you're still seeing it.
from octokit.rb.
I don't have permission to re-open the issue. I currently get a "bad request" error:
/.rvm/gems/ruby-1.9.3-p194@redmine/gems/octokit-1.15.1/lib/faraday/response/raise_octokit_error.rb:10:in on_complete': PUT https://api.github.com/repos/backlogs/redmine_backlogs/issues/700/labels?access_token=2bd147935d6a3f1ab33c4ebd8ee6b3ce7688e33e: 400: Body should be a JSON Array (Octokit::BadRequest) from /home/hnse/.rvm/gems/ruby-1.9.3-p194@redmine/gems/faraday-0.8.4/lib/faraday/response.rb:9:in
block in call'
from /home/hnse/.rvm/gems/ruby-1.9.3-p194@redmine/gems/faraday-0.8.4/lib/faraday/response.rb:63:in on_complete' from /home/hnse/.rvm/gems/ruby-1.9.3-p194@redmine/gems/faraday-0.8.4/lib/faraday/response.rb:8:in
call'
from /home/hnse/.rvm/gems/ruby-1.9.3-p194@redmine/gems/faraday_middleware-0.8.8/lib/faraday_middleware/request/encode_json.rb:23:in call' from /home/hnse/.rvm/gems/ruby-1.9.3-p194@redmine/gems/faraday-0.8.4/lib/faraday/connection.rb:226:in
run_request'
from /home/hnse/.rvm/gems/ruby-1.9.3-p194@redmine/gems/faraday-0.8.4/lib/faraday/connection.rb:99:in put' from /home/hnse/.rvm/gems/ruby-1.9.3-p194@redmine/gems/octokit-1.15.1/lib/octokit/request.rb:41:in
request'
from /home/hnse/.rvm/gems/ruby-1.9.3-p194@redmine/gems/octokit-1.15.1/lib/octokit/request.rb:22:in put' from /home/hnse/.rvm/gems/ruby-1.9.3-p194@redmine/gems/octokit-1.15.1/lib/octokit/client/labels.rb:138:in
replace_all_labels'
from ./lib/tasks/manage-issues.rb:72:in `labels'
With line 72 reading
CLIENT.replace_all_labels(REPO, @issue.number, @labels) # @labels is an array of strings
from octokit.rb.
Since your token was included in the backtrace I reset it for you. Please treat those as you would a password.
I'm only able to reproduce this by passing an empty array []
. Are you 100% sure @labels is populated?
from octokit.rb.
Yikes! Thanks. In some cases the array is empty, yes.
from octokit.rb.
Replacing replace_all with delete_all for empty labels list works!
from octokit.rb.
Awesome. It looks like the issue with [] is a GitHub API issue. I'm investigating.
Wynn Netherland
On Friday, October 5, 2012 at 8:51 AM, friflaj wrote:
Replacing replace_all with delete_all for empty labels list works!
—
Reply to this email directly or view it on GitHub (#104 (comment)).
from octokit.rb.
Related Issues (20)
- [FEAT]: Add support for generating release notes content for a release
- [BUG]: `check_runs_for_check_suite` generates invalid path if a repo string is passed in HOT 1
- Karatbars
- [FEAT]: Add support for SARIF data upload
- [MAINT]: Extend TooManyRequests test to check that the error message still differentiates between primary & secondary rate limits.
- [FEAT]: Support for codespaces and dependabot secrets HOT 1
- [DOCS]: Broken link for request-reviewers-for-a-pull-request HOT 2
- [FEAT]: Support codespaces API HOT 1
- [FEAT]: Support for Environment based Repository Secrets HOT 1
- [FEAT]: Add methods for app webhooks HOT 1
- [BUG]: Fetch a given reference uses the wrong API HOT 5
- [FEAT]: add missing endpoints HOT 2
- [BUG]: OAuth token auth applies a different Authorization header than using curl or postman HOT 6
- [DOCS]: README and yardocs refer to deleted method `#create_authorization` HOT 1
- [FEAT]: Refresh a user's access token with refresh token HOT 1
- Test issue HOT 1
- [FEAT]: Support Org Secrets HOT 1
- Get Projects by personal access token-Must have admin rights to Repository HOT 1
- [FEAT]: Provide response types with Sorbet HOT 1
- [BUG]: HTTP caching middleware returns cached responses to wrong users HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from octokit.rb.