Skip to content

Include inapplicable_reason in API response

Patrick Bajao requested to merge 219455-inappliable-reason-api into master

What does this MR do?

In order for frontend to display appropriate messages on why a suggestion can't be applied, it needs to know the reason.

A new inapplicable_reason property is introduced and included in the API response to achieve that. It is based on the checks to determine whether a suggestion can be applied.

The following reasons are:

  • "You don't have write access to the source branch." - when user has no write access to branch.
  • "This merge request was merged. To apply this suggestion, edit this file directly." - when MR was merged.
  • "This merge request is closed. To apply this suggestion, edit this file directly." - when MR is closed.
  • "Can't apply as the source branch was deleted." - when source branch is deleted.
  • "Can't apply as this line was changed in a more recent version." - when the line where suggestion is on is outdated.
  • "Can't apply as these lines were changed in a more recent version." - when lines where suggestion is on are outdated.
  • "This suggestion already matches its content." - when suggestion has the same content as the line it is on.
  • "Can't apply this suggestion." - default message when suggestion cannot be applied but doesn't fall into any of criteria above. We won't show this message anywhere right now but it makes sense to return something (e.g. when suggestion is already applied).

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

#219455 (closed)

Edited by Kerri Miller

Merge request reports