Version
▸ yamlfmt --version
yamlfmt v0.21.0
Description
Running yamlfmt multiple times on the same file produces different output each time. The file keeps growing with additional blank lines.
Minimal Reproducible Example
config:
sqlQuery: >-
SELECT
id,
name
FROM table
▸ xxd tmp.yaml
00000000: 636f 6e66 6967 3a0a 2020 7371 6c51 7565 config:. sqlQue
00000010: 7279 3a20 3e2d 0a20 2020 2053 454c 4543 ry: >-. SELEC
00000020: 540a 2020 2020 2020 6964 2c0a 2020 2020 T. id,.
00000030: 2020 6e61 6d65 0a20 2020 2046 524f 4d20 name. FROM
00000040: 7461 626c 650a table.
Run yamlfmt multiple times:
▸ md5sum tmp.yaml; yamlfmt tmp.yaml # e33add58f9e0e4b84aeb71a61c267d8e
▸ md5sum tmp.yaml; yamlfmt tmp.yaml # 7a3e92a06e68c33a5182d292fdae70ba
▸ md5sum tmp.yaml; yamlfmt tmp.yaml # ab174fb2a78b3c453e4bd7e104325e27
Expected Behavior
Output should be identical after the first run.
Actual Behavior
Each run produces a different checksum:
e33add58f9e0e4b84aeb71a61c267d8e tmp.yaml (original)
7a3e92a06e68c33a5182d292fdae70ba tmp.yaml (after run 1)
ab174fb2a78b3c453e4bd7e104325e27 tmp.yaml (after run 2)
846858c950577d0ba4a0225038abb602 tmp.yaml (after run 3)
After three consecutive yamlfmt tmp.yaml runs
▸ cat tmp.yaml
config:
sqlQuery: >-
SELECT
id,
name
FROM table
▸ xxd tmp.yaml
00000000: 636f 6e66 6967 3a0a 2020 7371 6c51 7565 config:. sqlQue
00000010: 7279 3a20 3e2d 0a20 2020 2053 454c 4543 ry: >-. SELEC
00000020: 540a 0a0a 0a20 2020 2020 2069 642c 0a20 T.... id,.
00000030: 2020 2020 206e 616d 650a 2020 2020 4652 name. FR
00000040: 4f4d 2074 6162 6c65 0a OM table.
The file grows, with blank lines being continuously added.
Workaround
De-indent lines 4 and 5 in the original tmp.yaml file. Consecutive runs of yamlfmt now produce stable output.
▸ cat tmp.yaml
config:
sqlQuery: >-
SELECT
id,
name
FROM table
▸ md5sum tmp.yaml; xxd tmp.yaml; yamlfmt tmp.yaml
6c9e5f19314fb1b5dc7d7ec1a982e485 tmp.yaml
00000000: 636f 6e66 6967 3a0a 2020 7371 6c51 7565 config:. sqlQue
00000010: 7279 3a20 3e2d 0a20 2020 2053 454c 4543 ry: >-. SELEC
00000020: 5420 0a20 2020 2069 642c 200a 2020 2020 T . id, .
00000030: 6e61 6d65 200a 2020 2020 4652 4f4d 2074 name . FROM t
00000040: 6162 6c65 0a able.
▸ md5sum tmp.yaml; xxd tmp.yaml; yamlfmt tmp.yaml
eae04f655ee477d9ca6f156e16563ebb tmp.yaml
00000000: 636f 6e66 6967 3a0a 2020 7371 6c51 7565 config:. sqlQue
00000010: 7279 3a20 3e2d 0a20 2020 2053 454c 4543 ry: >-. SELEC
00000020: 5420 2069 642c 2020 6e61 6d65 2020 4652 T id, name FR
00000030: 4f4d 2074 6162 6c65 0a OM table.
▸ md5sum tmp.yaml; xxd tmp.yaml; yamlfmt tmp.yaml
eae04f655ee477d9ca6f156e16563ebb tmp.yaml
00000000: 636f 6e66 6967 3a0a 2020 7371 6c51 7565 config:. sqlQue
00000010: 7279 3a20 3e2d 0a20 2020 2053 454c 4543 ry: >-. SELEC
00000020: 5420 2069 642c 2020 6e61 6d65 2020 4652 T id, name FR
00000030: 4f4d 2074 6162 6c65 0a OM table.
Version
Description
Running yamlfmt multiple times on the same file produces different output each time. The file keeps growing with additional blank lines.
Minimal Reproducible Example
Run yamlfmt multiple times:
Expected Behavior
Output should be identical after the first run.
Actual Behavior
Each run produces a different checksum:
After three consecutive
yamlfmt tmp.yamlrunsThe file grows, with blank lines being continuously added.
Workaround
De-indent lines 4 and 5 in the original
tmp.yamlfile. Consecutive runs ofyamlfmtnow produce stable output.