Skip to content

Resolve "Error 500 for /api/v4/projects/ID/services/jira"

What does this MR do?

This MR fixes a NoMethodError (undefined method slice for nil:NilClass) that occurs at /api/v4/projects/:id/services/:service when :service is an issue tracker service and has not yet been enabled for the project.

In this particular case, the IssueTrackerService is instantiated but is not persisted to the database. The check for service.data_fields_present? in lib/api/entities.rb returns false and this results in service.properties.slice being called, which results in the NoMethodError.

The proposed solution is to only check data_fields.present? if the service is not persisted. My other thought was to simply change data_fields.persisted? to data_fields.present?, but that resulted in failing tests in spec/requests/api/services_spec.rb. I think we could update the tests there if we wanted to only check data_fields.present? in data_fields_present?

Screenshots

Before (http://localhost:3000/api/v4/projects/7/services/jira)

Screen_Shot_2019-10-31_at_4.14.59_PM

After (http://localhost:3000/api/v4/projects/7/services/jira)

Screen_Shot_2019-10-31_at_4.16.07_PM

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Closes #34770 (closed)

Edited by 🤖 GitLab Bot 🤖

Merge request reports