Getting 'yaml invalid' error frequently / randomly even tho yaml is validated by linter.

Summary

Getting yaml invalid error randomly even tho yaml is validated by linter.

Steps to reproduce

We've few nested .gitlab-ci.yml files in our repository.

.gitlab-ci.yml file in a root directory.

variables:
  DOCKER_DRIVER: overlay2

default:
  image: docker:19.03
  services:
    - docker:19.03-dind

stages:
  - docs
  - test
  - build

include:
- local: '/docs/.docs.gitlab-ci.yml'
- local: '/ui/.ui.gitlab-ci.yml'
- local: '/widgets/.widgets.gitlab-ci.yml'

.ui.gitlab-ci.yml file.

ui:test:
  stage: test
  image: node:10.16-alpine
  before_script:
    - cd ui
    - yarn install
    - apk add --no-cache --update git
    - git checkout ${CI_COMMIT_REF_NAME}
  script:
    - yarn lint
    - yarn tsc
    - yarn build
  rules:
    - changes:
        - ui/**/*
  cache:
    key:
      files:
        - ui/package.json
    paths:
      - ui/node_modules/
  artifacts:
    expire_in: 1h
    paths:
      - ui/build/

ui:build:
  stage: build
  needs:
    - ui:test
  before_script:
    - docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
  script:
    - cd ui
    - docker build -t erxes/$CI_PROJECT_NAME:${CI_COMMIT_REF_NAME} -f Dockerfile .
    - docker push erxes/$CI_PROJECT_NAME:${CI_COMMIT_REF_NAME}
  dependencies:
    - ui:test
  only:
    refs:
      - master
      - develop
      - apm

Example Project

You can take a look at our project here.

What is the current bug behavior?

We're getting yaml invalid error randomly.

What is the expected correct behavior?

Gitlab CI/CD works normal.

Relevant logs and/or screenshots

Direct link to our failed pipeline.

Output of checks

This bug happens on GitLab.com

Possible fixes

This bug could be related to include or needs feature.