-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emitter emits extra space when emitting null values #46
Comments
Please don't create ending whitespace. Many projects' git repos or continuous integration (CI) process will automatically reject trailing whitespace. For example, the [CII best practices badge](https://github.com/linuxfoundation/cii-best-practices-badge] CI process run "git diff --check" to find any trailing whitespace & rejects commits that include them. |
The "translation:sync" task syncs up the translations, but uses the usual YAML writer, which writes out trailing whitespace. It should not do that, and the trailing whitespace causes later failures in testing. Problem already reported: - translation/rails#13 - yaml/libyaml#46 For now, we'll run this enhancement to solve the problem. Signed-off-by: David A. Wheeler <dwheeler@dwheeler.com>
This looks like a long standing bug. The rails solution simply removes trailing whitespace after generating the file. Why not fix it directly here? |
See issue yaml#46 Passing emitter tests: * 2XXW: Spec Example 2.25. Unordered Sets * 5WE3: Spec Example 8.17. Explicit Block Mapping Entries * 6KGN: Anchor for empty node * 6XDY: Two document start markers * 7W2P: Block Mapping with Missing Values * 8KB6: Multiline plain flow mapping key without value * 9BXH: Multiline doublequoted flow mapping key without value * C2DT: Spec Example 7.18. Flow Mapping Adjacent Values * JTV5: Block Mapping with Multiline Scalars * KK5P: Various combinations of explicit block mappings * LE5A: Spec Example 7.24. Flow Nodes * UT92: Spec Example 9.4. Explicit Documents * W42U: Spec Example 8.15. Block Sequence Entry Types * W4TN: Spec Example 9.5. Directives Documents * ZWK4: Key with anchor after missing explicit mapping value
See issue yaml#46 Passing emitter tests: * 2XXW: Spec Example 2.25. Unordered Sets * 5WE3: Spec Example 8.17. Explicit Block Mapping Entries * 6KGN: Anchor for empty node * 6XDY: Two document start markers * 7W2P: Block Mapping with Missing Values * 8KB6: Multiline plain flow mapping key without value * 9BXH: Multiline doublequoted flow mapping key without value * C2DT: Spec Example 7.18. Flow Mapping Adjacent Values * JTV5: Block Mapping with Multiline Scalars * KK5P: Various combinations of explicit block mappings * LE5A: Spec Example 7.24. Flow Nodes * UT92: Spec Example 9.4. Explicit Documents * W42U: Spec Example 8.15. Block Sequence Entry Types * W4TN: Spec Example 9.5. Directives Documents * ZWK4: Key with anchor after missing explicit mapping value
See issue yaml#46 Passing emitter tests: * 2XXW: Spec Example 2.25. Unordered Sets * 5WE3: Spec Example 8.17. Explicit Block Mapping Entries * 6KGN: Anchor for empty node * 6XDY: Two document start markers * 7W2P: Block Mapping with Missing Values * 8KB6: Multiline plain flow mapping key without value * 9BXH: Multiline doublequoted flow mapping key without value * C2DT: Spec Example 7.18. Flow Mapping Adjacent Values * JTV5: Block Mapping with Multiline Scalars * KK5P: Various combinations of explicit block mappings * LE5A: Spec Example 7.24. Flow Nodes * UT92: Spec Example 9.4. Explicit Documents * W42U: Spec Example 8.15. Block Sequence Entry Types * W4TN: Spec Example 9.5. Directives Documents * ZWK4: Key with anchor after missing explicit mapping value
See issue yaml#46 Passing emitter tests: * 2XXW: Spec Example 2.25. Unordered Sets * 5WE3: Spec Example 8.17. Explicit Block Mapping Entries * 6KGN: Anchor for empty node * 6XDY: Two document start markers * 7W2P: Block Mapping with Missing Values * 8KB6: Multiline plain flow mapping key without value * 9BXH: Multiline doublequoted flow mapping key without value * C2DT: Spec Example 7.18. Flow Mapping Adjacent Values * JTV5: Block Mapping with Multiline Scalars * KK5P: Various combinations of explicit block mappings * LE5A: Spec Example 7.24. Flow Nodes * UT92: Spec Example 9.4. Explicit Documents * W42U: Spec Example 8.15. Block Sequence Entry Types * W4TN: Spec Example 9.5. Directives Documents * ZWK4: Key with anchor after missing explicit mapping value
I created a PR for fixing this: #186 It was easier than I thought, because the emitter does not output the space directly after the |
See issue yaml#46 Passing emitter tests: * 2XXW: Spec Example 2.25. Unordered Sets * 5WE3: Spec Example 8.17. Explicit Block Mapping Entries * 6KGN: Anchor for empty node * 6XDY: Two document start markers * 7W2P: Block Mapping with Missing Values * 8KB6: Multiline plain flow mapping key without value * 9BXH: Multiline doublequoted flow mapping key without value * C2DT: Spec Example 7.18. Flow Mapping Adjacent Values * JTV5: Block Mapping with Multiline Scalars * KK5P: Various combinations of explicit block mappings * LE5A: Spec Example 7.24. Flow Nodes * UT92: Spec Example 9.4. Explicit Documents * W42U: Spec Example 8.15. Block Sequence Entry Types * W4TN: Spec Example 9.5. Directives Documents * ZWK4: Key with anchor after missing explicit mapping value
See issue yaml#46 Passing emitter tests: * 2XXW: Spec Example 2.25. Unordered Sets * 5WE3: Spec Example 8.17. Explicit Block Mapping Entries * 6KGN: Anchor for empty node * 6XDY: Two document start markers * 7W2P: Block Mapping with Missing Values * 8KB6: Multiline plain flow mapping key without value * 9BXH: Multiline doublequoted flow mapping key without value * C2DT: Spec Example 7.18. Flow Mapping Adjacent Values * JTV5: Block Mapping with Multiline Scalars * KK5P: Various combinations of explicit block mappings * LE5A: Spec Example 7.24. Flow Nodes * UT92: Spec Example 9.4. Explicit Documents * W42U: Spec Example 8.15. Block Sequence Entry Types * W4TN: Spec Example 9.5. Directives Documents * ZWK4: Key with anchor after missing explicit mapping value
See issue #46 Passing emitter tests: * 2XXW: Spec Example 2.25. Unordered Sets * 5WE3: Spec Example 8.17. Explicit Block Mapping Entries * 6KGN: Anchor for empty node * 6XDY: Two document start markers * 7W2P: Block Mapping with Missing Values * 8KB6: Multiline plain flow mapping key without value * 9BXH: Multiline doublequoted flow mapping key without value * C2DT: Spec Example 7.18. Flow Mapping Adjacent Values * JTV5: Block Mapping with Multiline Scalars * KK5P: Various combinations of explicit block mappings * LE5A: Spec Example 7.24. Flow Nodes * UT92: Spec Example 9.4. Explicit Documents * W42U: Spec Example 8.15. Block Sequence Entry Types * W4TN: Spec Example 9.5. Directives Documents * ZWK4: Key with anchor after missing explicit mapping value
Released 0.2.5! |
Thank you! |
The folks behind libyaml decided to change it so it was less likely to emit trailing whitespace. That's good for them, but bad for us. We've been using MD5 hashes of those YAML dumps for our recordings and now those MD5 hash values are different. Eventually we'll want to settle towards the new behavior. But we can't just go updating the hashes; some dev machines / build bots / whatever still have the old libyaml and would be confused by the new hashes. This ugly hack is good enough to keep tests passing in either libyaml version, for now. Hopefully it'll get us over the hump and we can remove it and re-record the tests alter. I think this is the PR that changed the behavior: yaml/libyaml#46
[STAR-2408](https://outreach-io.atlassian.net/browse/STAR-2408) The folks behind libyaml decided to change it so it was less likely to emit trailing whitespace. That's good for them, but bad for us. We've been using MD5 hashes of those YAML dumps for our recordings and now those MD5 hash values are different. Eventually we'll want to settle towards the new behavior. But we can't just go updating the hashes; some dev machines / build bots / whatever still have the old libyaml and would be confused by the new hashes. This ugly hack is good enough to keep tests passing in either libyaml version, for now. Hopefully it'll get us over the hump and we can remove it and re-record the tests alter. I think this is the PR that changed the behavior: yaml/libyaml#46
If you look at
https://github.com/yaml/libyaml-test/blob/master/test/libyaml-emitter.skip#L4
you'll see that the emitter test skips 12 tests because libyaml emits an extra
space at the end of a line where an empty string is emitted for a null value.
Using underscore to show a space char, libyaml emits:
To emit this data:
This is obviously because libyaml emits a space right after
-
or:
which isright most of the time.
Depending on when the output buffer is actually flushed, we might be able to do
an easy fix of backing up before the space when we get to a null value. Need to
look at the code.
The text was updated successfully, but these errors were encountered: