Get "Response code = 500" error randomly when running cucumber - ruby-on-rails

For some reason I keep getting a response code of 500 when I run cucumber, even though all the tests pass. The error occurs randomly for different tests, every time I run it. Sometimes all tests pass as well.
I thought it was a memory issue, so I tried restarting my computer, but that didn't do anything.
An example of the error is:
And I follow "link" # features/step_definitions/web_steps.rb:33
Failed. Response code = 500. Response message = Internal Server Error. (ActiveResource::ServerError)
./app/controllers/companies_controller.rb:23:in `show'
./features/step_definitions/web_steps.rb:35
./features/step_definitions/web_steps.rb:14:in `with_scope'
./features/step_definitions/web_steps.rb:34:in `/^(?:|I )follow "([^"]*)"(?: within "([^"]*)")?$/'
features/manage_sites.feature:256:in `And I follow "link"'
It seems related to the tagging feature. I was using the #wip tag, and when I moved it around, it would cause the sporadic 500 errors. Removing all #wip tags makes all the tests pass.
I could be wrong though. I'll need to try and replicate it consistently.
Would anybody be able to help?

Related

For what reason can an error occur periodically in the client-side?

I have a Rails application that has several components written in Vue. All components are included in the "pack" file.
These two errors occur periodically in the browser (Safari):
SyntaxError: Unexpected token '|'
TypeError: Object(i.a) is not a function. (In 'Object(i.a)()', 'Object(i.a)' is an instance of Object)
The first error points to this line:
<meta name="csrf-token" content="qRbwC3xngly9Y5hRVLA86upHTEkVwIk10PiOtDWCw00RUkIhGK8UvEIhtUXebkzWaqlxsHPSBaheR1moaY-b9w"/>
I don't understand what the second line points to. The error refers to some function "c" in "node.js:15".
Clicking on it jumps to the comment:
In general, I do not understand what it is.
If reload the page, then everything will be fine. Well, that is the problem occurs randomly.
On the Sentry side, I get nothing. Apparently, this does not reach Sentry, the error is not caught and is not transmitted to Sentry.

undefined method `+' for nil:NilClass in sample saml application

Trying to follow the setup here to create a simple SAML application (full project I got here).
I went through and did the setup
bundle install
rails s
This went fine, but when I navigate to
http://localhost:3000/
I get hit with
NoMethodError in SamlController#init
undefined method `+' for nil:NilClass
Extracted source (around line #9):
def init
request = OneLogin::RubySaml::Authrequest.new
direct_to(request.create(saml_settings))
end
def consume
I added some logging to check nil status of request and saml_settings but that seems to return false for both of them
puts request.nil?
puts saml_settings.nil?
Error trace:
Processing by SamlController#init as HTML
false
false
Created AuthnRequest: <samlp:AuthnRequest AssertionConsumerServiceURL='http://localhost:3000/saml/consume' ID='_394fa0a0-f313-0135-85a4-6a0001e18280' IssueInstant='2018-02-13T17:42:45Z' Version='2.0' xmlns:saml='urn:oasis:names:tc:SAML:2.0:assertion' xmlns:samlp='urn:oasis:names:tc:SAML:2.0:protocol'><saml:Issuer>http://localhost:3000/saml/consume</saml:Issuer></samlp:AuthnRequest>
Completed 500 Internal Server Error in 15ms (ActiveRecord: 0.0ms)
NoMethodError (undefined method `+' for nil:NilClass):
app/controllers/saml_controller.rb:9:in `init'
(Note: the error is line 5, it says line 9 for me because of debug logging I added)
I'm not too sure what else it could be, not sure what method it can't find and what is nil?
I have never messed with ruby stuff, but from my initial looks I'm not sure where the nil is coming from, the logs show the request being created so not sure. Any help would be appreciated, thanks!
Firstly I think you're using a pretty old ruby-saml gem version. That might be the problem.
I haven't tested your code, but it seems to me that you forgot to set idp_sso_target_url in your settings, and apparently that's the only place it can throw the exception you got. https://github.com/onelogin/ruby-saml/blob/v1.1.2/lib/onelogin/ruby-saml/authrequest.rb#L39
Posting the answer here, turns out that i was using a metadata url for the OKTA_METADATA environment variable.
Had to modify
settings = idp_metadata_parser.parse(ENV['OKTA_METADATA'])
to
settings = idp_metadata_parser.parse_remote(ENV['OKTA_METADATA'])
where
OKTA_METADATA=http://blahblahblah.com/metadata

On production server at one page I am getting Fatal error ActionView::Template::Error

I am getting this error " ActionView::Template::Error (bad component(expected host component): ): ", on research on stackoverflow I observed this error is occurring on wrong config of mailer. But I have not configured any mails.
From the details shared , the first line indicates error in fetching the data.
A line of action to resolve this could be,
first to check the correctness of data fetch using rails console/sandbox environment.
Once point 1 above is sorted out and still error, then have a look at the view and check the rendering/flow.
This will point you to the error.

How to debug sidekiq?

Today airbrake reported an exception. Its summary said that the problem occures when sidekiq tries retry the job after a failure. Here's what summary params look like:
{
"retry"=>"true",
"queue"=>"default",
"class"=>"AdwordsReportWorker",
"args"=>"[\"2\", \"2012-11-13\"]",
"jid"=>"51d568e46c412adc327153c8",
"error_message"=>"wrong number of arguments(1 for 0)",
"error_class"=>"ArgumentError",
"failed_at"=>"2012-11-14 13:56:12 UTC",
"retry_count"=>"0",
"controller"=>"",
"action"=>""
}
I seems that the exception is only taking palce when the job fails and retries. I would like to debug this, but I can't get my head around where to start :-(
My questions are:
Under what conditions worker understands it failed finishing the job (from which he descides to retry)? How do I force the worker to fail in attempt to, say, reproduce the problem?
Is there a good tutorial on debugging/examples sidekiq workers?
I am using sidekiq 2.3.3. Will upgrading to newer version solve the problem?
Bonus track.
The actual stacktrace unexpectedly ends up in
[GEM_ROOT]/gems/activerecord-3.2.8/lib/active_record/associations/association.rb:98:in `initialize'
I couldn't find how do debug sidekiq, but apperently the problem I am referring to is a known bug in Rails.
Here are a few lines:
https://github.com/mperham/sidekiq/issues/601
https://github.com/rails/rails/issues/7770

Weird rails error while loading the application

I am having this bizarre error and I don't know what to do.
This code runs fine on my development and staging machine but crashes on production.
All I have to do is load the page or call script/server to trigger the following error:
Error message:
interning empty string
Exception class:
ArgumentError
Full Stack trace: Code
Sorry for this short description, but this is all that i am able to show to you. =/
Thank you.
This could be because you have an invalid filename for a partial (a filename with two consecutive zeros).
For example
_partial..html.erb (invalid)
This blog post mentions this error:
http://anaphoral.blogspot.com/2009/04/rails-interning-empty-string.html

Resources