I cannot create new issue through with REST API - ruby

I'm troubled with redmine.
When I create new issue with Rest API(from Microsoft Excel), Internal Error 500 happened.
Seeing from production.log, "NoMethodError" is happened (see below message)
Started POST "/redmine/issues.xml?key=XXXXXXX" for XX.XX.XX.XXX at 2016-05-30 14:44:10 +0900
Processing by IssuesController#create as XML Parameters: {"issue"=>`
{"project_id"=>"mt001", "subject"=>"TEST_AI", "tracker_id"=>"6",
"category_id"=>"136", "assigned_to_id"=>"4", "fixed_version_id"=>"93",
"priority_id"=>"2", "parent_issue_id"=>nil,
"start_date"=>"2016-05-30", "due_date"=>"2016-06-01",
"description"=>"Redmine TEST AI", "status_id"=>"1"},
"key"=>"XXXXXXX(hidden for security"}
Current user: user1 (id=65)
Completed 500 Internal Server Error in 367ms (ActiveRecord: 19.9ms)
NoMethodError (undefined method `shared_versions' for nil:NilClass):
app/models/issue.rb:823:in `assignable_versions'
app/models/issue.rb:643:in `validate_issue'
app/controllers/issues_controller.rb:141:in `create'
lib/redmine/sudo_mode.rb:63:in `sudo_mode'
So, I tried to create new issew using web browser (IE11).
The ticket was created normally. Here is production.log.
Started POST "/redmine/projects/mt001/issues" for XX.XX.XX.XXX at 2016-05-30 14:58:23 +0900
Processing by IssuesController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"QF1BA5MgwysJsAiFfT/h95DeZ/VgzSGOnryR6xUn4mmWpf7EZ8XFJqpaye/ZLXrKR/wV00dKOz8KbhP94VcUyg==", "form_update_triggered_by"=>"", "issue"=>{"tracker_id"=>"6", "subject"=>"Test2", "description"=>"This is test", "status_id"=>"1", "priority_id"=>"2", "assigned_to_id"=>"4", "category_id"=>"132", "fixed_version_id"=>"127", "parent_issue_id"=>"", "start_date"=>"2016-05-30", "due_date"=>"2016-06-03", "custom_field_values"=>{"12"=>"", "41"=>""}}, "was_default_status"=>"1", "commit"=>"create", "project_id"=>"mt001"}
Current user: user1 (id=65)
Rendered mailer/_issue.text.erb (7.1ms)
Rendered mailer/issue_add.text.erb within layouts/mailer (9.8ms)
Rendered mailer/_issue.html.erb (3.0ms)
Rendered mailer/issue_add.html.erb within layouts/mailer (5.1ms)
Redirected to http://mydepartment.co.jp/redmine/issues/1717
Completed 302 Found in 3697ms (ActiveRecord: 130.3ms)
I already tried to migrate, clear cache.
What should I do next.
Here is my environment on RHEL7.2
Environment:
Redmine version 3.2.0.stable
Ruby version 2.2.4-p230 (2015-12-16) [x86_64-linux]
Rails version 4.2.5
Environment production
Database adapter Mysql2
SCM:
Subversion 1.7.14
Git 1.8.3.1
Filesystem
Redmine plugins:
redmine_export_with_journals 0.0.8
redmine_importer 1.2.2
redmine_local_avatars 1.0.0
redmine_xlsx_format_issue_exporter 0.1.2
sidebar_hide 0.0.7
Here is assinable_versions source-code
# Versions that the issue can be assigned to
def assignable_versions
return #assignable_versions if #assignable_versions
versions = project.shared_versions.open.to_a #Here is line823
if fixed_version
if fixed_version_id_changed?
# nothing to do
elsif project_id_changed?
if project.shared_versions.include?(fixed_version)
versions << fixed_version
end
else
versions << fixed_version
end
end
#assignable_versions = versions.uniq.sort
end

The error is occurring because project is nil and you are trying to call nil.shared_versions. So change the if condition:
if !project.shared_versions.nil?
versions = project.shared_versions.open.to_a
end
to as follows:
versions = project.shared_versions.open.to_a unless project.nil?
This will resolve the 'undefined method' error.

I've solved problem.
There is some difference of REST process.
At least redmine 2.4.4, I can use both project_id = identifier and project_id = project_id for issue create.
But, redmine 3.x, I can only use project_id = project_id for issue create.

Related

Weird "is_xhr" error when deploying Flask app to Heroku

I have a flask app which I've deployed to Heroku, one of the routes is the following
def get_kws():
seed_kw = request.json['firstParam']
audience_max = request.json['secondParam']
interest_mining_service = InterestMiningService(seed_kw, audience_max)
query_result = interest_mining_service.query_keyword().tolist()
if seed_kw in query_result:
print ("yes")
return jsonify(
{
'keyword_data' : interest_mining_service.find_kws().to_json(orient='records'),
'query_results': query_result
}
)
When I test this endpoint locally, I have no issues when sending POST and GET requests to that endpoint. However, when I deploy to Heroku, I get the following error:
File "/app/server/controller.py", line 24, in get_kws
2020-02-08T22:31:05.893850+00:00 app[web.1]: 'query_results': query_result
2020-02-08T22:31:05.893850+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/json.py", line 298, in jsonify
2020-02-08T22:31:05.893851+00:00 app[web.1]: if current_app.config['JSONIFY_PRETTYPRINT_REGULAR'] and not request.is_xhr:
2020-02-08T22:31:05.893851+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/werkzeug/local.py", line 347, in __getattr__
2020-02-08T22:31:05.893852+00:00 app[web.1]: return getattr(self._get_current_object(), name)
2020-02-08T22:31:05.893858+00:00 app[web.1]: AttributeError: 'Request' object has no attribute 'is_xhr'
I've never seen this error Request object has no attribute 'is_xhr' before and it only seems to be happening when I deploy to Heroku. Any guidance on what I should look into?
There also doesn't seem to be an issue with the json key keyword_data - the issue seems limited to query_results which is a list.
The Werkzeug library (dependency from Flask) recently received a major update (0.16.1 --> 1.0.0) and it looks like Flask (<=0.12.4) does not restrict the version of Werkzeug that is fetched.
You have 2 options:
Stick with your current version of Flask and restrict the Werkzeug version that is fetched explicitly in your application's setup.py or requirements.txt by specifying werkzeug<1.0 or werkzeug==0.16.1
Upgrade to a recent version of Flask (>=1.0.0), which is running fine with latest Werkzeug
Or you can just forcefully install the bustard again by calling
pip install Werkzeug==0.16.1
I have faced with this problem too.
Just temporarily fixed by directly checking in request header
request.headers.get("X-Requested-With") == "XMLHttpRequest"
not sure this help ...

[passenger + apache + ruby]HTTP PUT file failed with transfer-encoder:chunked header when passengerbufferupload is off

envirment:
passenger 5.0.0
apache:2.4.6
passengerbufferupload off
Error:
when put file with transfer-encoder:chunked by http request, can't get file content from apache.
apache error log:
App 22178 stderr: [ 2018-06-13 10:17:35.9345 22203/0x0055710edcfa58(Worker 1) request_handler/thread_handler.rb:219 ]: *** Passenger RequestHandler warning: HTTP header size exceeded maximum.
Investigate
I confirmed the transfer-encoder header in the passenger by print log.
the transfer-encoder header is HTTP_TRANSFER_ENCODING:CHUNKED.
I confirmed the source of passenger, too. In the source, when get transfer-encoder header, it used 'TRANSFER_ENCODING'. so, can not get transfer-encoder header.
source:
phusion_passenger/utils/tee_input.rb
class TeeInput
CONTENT_LENGTH = "CONTENT_LENGTH".freeze
TRANSFER_ENCODING = "TRANSFER_ENCODING".freeze
phusion_passenger/request_handler/thread_handler.rb
TRANSFER_ENCODING = 'TRANSFER_ENCODING'.freeze
I also confirmed the source commit history.
from 4.0.60 to 5.0.0, modify the above sources.(from TRANSFER_ENCODING = "HTTP_TRANSFER_ENCODING".freeze to TRANSFER_ENCODING = "TRANSFER_ENCODING".freeze)
commit log:
https://github.com/phusion/passenger/commit/0766bb303ad8009c6061206f3aafe231c4f1c3ff ⇒tee_input.rb
https://github.com/phusion/passenger/commit/eee48f95fd9db0fb5b24458f9fb0b84a25acc6ae ⇒thread_handler.rb
question:
1.I want to know the reason of the modify.
2.this is an issue or not?
Passenger author here. This has been confirmed to be Passenger bug. Please see https://github.com/phusion/passenger/issues/2102.

Phantomjs headless on linux: WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP

I am experiencing issue with Phantomjs headless automation testing on linux. We are using Jenkins as our CI server. However, we are getting the error below:
phantomjs://platform/console++.js:263 in error
[ERROR - 2016-12-09T19:45:12.372Z] WebElementLocator -
_handleLocateCommand - Element(s) NOT Found: GAVE UP.
Search Stop Time: 1481312712354
phantomjs://platform/console++.js:263 in error
How we start phantomjs:
phantomjs --webdriver=8001
Environment:
Phantomjs: 2.1.1
Jenkins: 1.598
Linux: Linux xxx1247 2.6.32-573.12.1.el6.x86_64
Ruby: 1.9.3
Cucumber: 2.1.4
Selenium-webdriver: 2.53
Please share your solution. Thanks!
There can be a few causes for this. One of them can be that the get action to the Web URL failed. That means you are operating on an empty result, which will throw that error.
Since the webpage is not fetched, the element will not be there.

Redmine 500 Error When Viewing Issues + TypeError (no implicit conversion of Symbol into Integer)

I had some initial problems upgrading redmine from 2.0.3 to 2.4.2 and thought that I resolved them. However, now when I try to view issues, I receive a 500 internal server error. The production log entry corresponding to the issue is:
Started GET "/projects/mytradenote_com/issues" for xx.xxx.xxx.xx at 2014-02-18 21:20:45 +0000
Processing by IssuesController#index as HTML
Parameters: {"project_id"=>"xxxx"}
Current user: xxxx (id=x)
Completed 500 Internal Server Error in 17.8ms
TypeError (no implicit conversion of Symbol into Integer):
app/models/issue_query.rb:106:in `[]='
app/models/issue_query.rb:106:in `draw_relations='
app/models/issue_query.rb:120:in `build_from_params'
app/helpers/queries_helper.rb:197:in `retrieve_query'
app/controllers/issues_controller.rb:56:in `index'
I know NOTHING about ruby, but I think I was able to trace the issue to line 118 through 123 in issue_query.rb:
def build_from_params(params)
super
self.draw_relations = params[:draw_relations] || (params[:query] && params[:query][:draw_relations])
self.draw_progress_line = params[:draw_progress_line] || (params[:query] && params[:query][:draw_progress_line])
self
end
I commented out line 120 (self.draw_relations ...) and the last lines of the production.log error changed to:
app/models/issue_query.rb:115:in `[]='
app/models/issue_query.rb:115:in `draw_progress_line='
app/models/issue_query.rb:121:in `build_from_params'
app/helpers/queries_helper.rb:197:in `retrieve_query'
app/controllers/issues_controller.rb:56:in `index'
I then commented out line 121 (self.draw_progress_line ...) and I am now able to view the issues. I am guessing something is wrong with the draw_relations and draw_progress_line definitions. Although the issue appears to be resolved, I am concerned about potential issues as I don't know the consequence of commenting out those two lines will have in other areas of the program.
Any thoughts would be highly appreciated.
Thanks in advance.

Ruby crashes on windows

I'm facing same problem described here: why-rails-fails-with-ruby-exe-has-encountered-a-problem-and-needs-to-close. that is ruby get crashed with following error:
ruby.exe has encountered a problem and needs to close. We are sorry for the inconvenience.
I'm asking this to add some details on it as that question was not asked by me I am not able to add information in it. So this is not duplicate.
Ruby crashes eventually no matter how I run it (in development or in production), but it seems to crash more often in production mode. Sometimes it will crash when I hold down the F5 key, but sometimes I have to hold and release it intermittently for a minute or two. It appears to be very dependent on timing, but I can usually make it crash in less than 60 seconds.
When I refresh the GET request is sent for 3 times as follows:
Started GET "/app/page" for 127.0.0.1 at 2011-02-23 10:57:35 +0530
Processing by AppController#page as HTML
Rendered pms/dashboard.html.erb within layouts/application (109.4ms)
Completed 200 OK in 141ms (Views: 140.6ms | ActiveRecord: 0.0ms)
Started GET "/app/page" for 127.0.0.1 at 2011-02-23 10:57:35 +0530
Processing by AppController#page as */*
Rendered pms/dashboard.html.erb within layouts/application (15.6ms)
Completed 200 OK in 187ms (Views: 187.5ms | ActiveRecord: 0.0ms)
Started GET "/app/page" for 127.0.0.1 at 2011-02-23 10:57:35 +0530
Processing by AppController#page as */*
Rendered pms/dashboard.html.erb within layouts/application (15.6ms)
Completed 200 OK in 219ms (Views: 218.7ms | ActiveRecord: 0.0ms)
And if I rapidly refresh the page get following error in one of or all the 3 request:
ERROR Errno:ECONNABORTED: An established connection was aborted by the software in your host machine:
c:/Ruby/lib/1.9.1/webrick/httpresponse.rb:323:in 'write'
c:/Ruby/lib/1.9.1/webrick/httprespose.rb:323:in '<<'
c:/Ruby/lib/1.9.1/webrick/httprespose.rb:323:in '_write_data'
c:/Ruby/lib/1.9.1/webrick/httprespose.rb:295:in 'send_body_string'
c:/Ruby/lib/1.9.1/webrick/httprespose.rb:186:in 'send_body'
c:/Ruby/lib/1.9.1/webrick/httprespose.rb:103:in 'send_response'
c:/Ruby/lib/1.9.1/webrick/httpserver.rb:86:in 'run'
ERROR Errno:ECONNABORTED: An established connection was aborted by the software in your host machine:
c:/Ruby/lib/1.9.1/webrick/httpserver.rb:56:in 'eof?'
c:/Ruby/lib/1.9.1/webrick/httpserver.rb:56:in 'run'
c:/Ruby/lib/1.9.1/webrick/server.rb:183:in 'block in start_thread'
INFO going to shutdown....
INFO WEBrick::HTTPServer#start done
When I started to get this error?
When I added images, css and javascript in my project I started to get this error. I also tried by removing one of this 3 and see who causes the error but every time my ruby.exe get crashed and i see the error:
ruby.exe has encountered a problem and needs to close. We are sorry for the inconvenience.
How can I solve this?
When I start server following is printed on console:
=>Booting WEBrick
=>Rails 3.0.3 application starting in development on http://0.0.0.0:3000
=>Call with -d to detach
=>Ctrl-C to shutdown server
[2011-02-23 10:59:22] INFO WEBrick 1.3.1
[2011-02-23 10:59:22] INFO ruby 1.9.2 (2010-08-18) [i386-mingw32]
[2011-02-23 10:59:22] INFO WEbrick::HTTPServer#start: pid:2448 port=3000
Output of ruby -v
ruby 1.9.2p0 (2010-08-18) [i386-mingw32]
... except the installer is now ALSO the crashing 1.9.2-p290
Workaround:
Add (or change)
config.log_level = :warn
in config/environments/development.rb
(not my solution - found it in another thread)
Running 1.9.2 on windows puts you in a REALLY small minority of users. If you don't have an explicit need for 1.9, I'd use 1.8.7. Specifically, I'd use the package from RailsInstaller: http://railsinstaller.org/
i got the same crashes on windows 7 with 1.9.2-p290. someone said to clear development.log file. i can't believe but after deleting my 12mb development.log everything works fine.
it is possible that a native (C) extension is failing and bringing the whole ruby down; in my case it was sql server adapter looping indefinitely/using whole heap; after we traced and fixed the bug in the adapter (https://github.com/rails-sqlserver/tiny_tds/pull/124) it does not fail again

Resources