Flaky "Invalid YAML" errors

I’ve been running into an issue occasionally (on gitlab.com) where I trigger a pipeline by pushing changes to my repo, and it fails with a yaml invalid error with some more detail like this:

  • ‘Image Push’ job needs ‘Image Build’ job, but ‘Image Build’ is not in any previous stage

But this only happens some of the time. So far, manually triggering it right afterwards has always worked, but as far as I can tell the times it fails are completely arbitrary. If I go to the pipeline editor, it acts as everything is fine. I don’t know of any way to get GitLab to give me the entire YAML it thinks is invalid.

The CI setup is somewhat complex, and given its flakiness I’m reluctant to spend time trying to create a minimal reproduction, but in case anything here makes it sound like a known issue, the basic structure is like this. The jobs are in fact in different stages, the stages are listed in the correct order in stages, but they’re connected to each other with needs, anyway. These jobs are defined in files pulled in with include:local by the top-level .gitlab-ci.yml and they extend hidden jobs defined in files pulled from a different repo. The hidden jobs are the ones that reference the stages, and stages: is in one of the files pulled from the other repo.

Does this sound familiar to anyone, or should I file a support request?