Skip to content

Imrpove model validation when adding spent time

Lee Tickett requested to merge 336970-improve-add-spent-time-error into master

What does this MR do?

We recently added support for setting timelog summary using the API, but the validation error simply statse invalid. This MR ensures the parent issuable validation error details the child (timelog) error messsage e.g. timelog.summary: is too long (maximum is 255 characters).

How to recreate/test

HTTP POST to: http://gdk.test:3000/api/v4/projects/2/merge_requests/7/add_spent_time

{
    "duration": 600,
    "summary": "The quick brown fox jumped over the lazy dogshe quick brown fox jumped over the lazy dogshe quick brown fox jumped over the lazy dogshe quick brown fox jumped over the lazy dogshe quick brown fox jumped over the lazy dogshe quick brown fox jumped over the lazy dogshe quick brown fox jumped over the lazy dogshe quick brown fox jumped over the lazy dogshe quick brown fox jumped over the lazy dogshe quick brown fox jumped over the lazy dogshe quick brown fox jumped over the lazy dogshe quick brown fox jumped over the lazy dogshe quick brown fox jumped over the lazy dogshe quick brown fox jumped over the lazy dogshe quick brown fox jumped over the lazy dogshe quick brown fox jumped over the lazy dogshe quick brown fox jumped over the lazy dogshe quick brown fox jumped over the lazy dogshe quick brown fox jumped over the lazy dogs!"
}

Response prior to this MR:

{
    "message": {
        "timelogs": [
            "is invalid"
        ]
    }
}

After this MR:

{
    "message": {
        "timelogs.summary": [
            "is too long (maximum is 255 characters)"
        ]
    }
}

Screenshots or Screencasts (strongly suggested)

image

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

How to setup and validate locally (strongly suggested)

Security

Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.

  • 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

Related to #336970

Merge request reports

Loading