apache / apache/buildstream

Yaml Dumper removes blank lines seemingly arbitrarily

Open
#767 13 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
140
Forks
45
Avg merge
1d 3h
Merged PRs (30d)
6

Description

[See original issue on GitLab](https://gitlab.com/BuildStream/buildstream/-/issues/767)
In GitLab by [[Gitlab user @coldtom]](https://gitlab.com/coldtom) on Nov 15, 2018, 15:14

## Summary

While working on the `bst fmt` command, I've run across a weird issue with the yaml dumping. It seems that dumping the yaml will sometimes remove all blank lines in a file, but not every time. It seems reliably reproducible by running `bst fmt` 3 times on a single file in [this branch](https://gitlab.com/BuildStream/buildstream/commits/coldtom/bst-fmt)

## Steps to reproduce

Either use `bst fmt` as in the branch above 3 times on a single element, or run `bst track` a few times on a single element, discarding the changes to the ref each time.

Running three times seems to get the behaviour to happen reliably, but sometimes the blank lines are removed after less runs than this.

## What is the current bug behavior?

Blank lines occasionally removed from files when yaml dumped.

## What is the expected correct behavior?

Blank lines should be left as they are.

## Possible fixes

I suspect this is a bug in ruamel.yaml.

* BuildStream version affected: /milestone %"BuildStream\_v1.2"

----

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue by running `bst fmt` three times on one element, or repeatedly running `bst track` while discarding ref changes, as described in the report. Start by tracing the YAML dumping path and checking the suspected `ruamel.yaml` behavior. Done means repeated dumps preserve existing blank lines consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.