You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SchemaPrinter generates different results on Windows #2973
The SchemaPrinter utility generates slightly different results for schemas that contain multi-line descriptions when run on Windows vs Linux/macOS.
For some reason, \r\n line endings are used for multi-line descriptions only, and an extra blank line is inserted after the opening """.
To Reproduce
Using a schema like so:
type Query {
"""
This does
something.
"""
myQuery: String
}
The SchemaPrinter will generate something like this on Windows (I'm using Java literals here for illustration - the actual results contain binary carriage returns and line feeds):
type Query {\n
"""\n
\r\n
This does\r\n
something.\r\n
"""\n
myQuery: String\n
}\n
On Unix-based systems, the results are as expected.
So interestingly, there were already some fixes done for this back in #2705. This PR removed usage of println which does emit OS-specific line ending characters.
I've scanned the code and I can't find anywhere that is generating \r characters, either directly or indirectly, but I have a sneaking suspicion in may be related to how Antlr is parsing the schema.
As mentioned in the issue description, these \r characters only appear in multi-line description strings, which is why I suspect the parser.
At any rate, here's my use case.
We commit to version control a copy of the full schema, generated using SchemaPrinter. The purpose of this file is to act as a "schema lock" file that we can use to compare new changes against.
We have a utility that uses SchemaDiff that developers can run to see if their changes contain breaking changes to the schema. This utility also regenerates an updated copy of the schema lock file if there are no breaking changes or the developer has indicated that breaking changes are ok.
In our CI, we then compare the generated schema against the committed schema lock file to make sure the files are identical.
If the diff/lock file generation tool is run on Windows, the generated file from SchemaPrinter is different if the schema contains multi-line descriptions.
For now, we are hacking around it by using a regex search and replace to strip the weird carriage returns and extra line that appears after the opening """.
The challenge we would have it testing any changes - we dont have easy access to Windows machines with the IDEA etc.. to develop a fix
I'm in the same boat, unfortunately. Feel free to close this out. If I have some spare time to investigate with a Windows VM I'll try to run things through a debugger to fine the source of these carriage returns, and if I get anywhere, I can reopen with more information (or submit a pull request).
Activity
bbakerman commentedon Oct 5, 2022
I suspect its based on the
printfbehavior in JavaWe have lots of code like
So perhaps the
printfcode uses the Windows\r\n(which is standard windows newline versus the Unix convention of just\n)\r\nis standard new line on Windows (if I recall back 10 years to when I last worked in Windows)So my question is - is this a problem for you in practice. What is not working as expected for you with this behavior?
ajkerr commentedon Oct 5, 2022
So interestingly, there were already some fixes done for this back in #2705. This PR removed usage of
printlnwhich does emit OS-specific line ending characters.I've scanned the code and I can't find anywhere that is generating
\rcharacters, either directly or indirectly, but I have a sneaking suspicion in may be related to how Antlr is parsing the schema.As mentioned in the issue description, these
\rcharacters only appear in multi-line description strings, which is why I suspect the parser.At any rate, here's my use case.
We commit to version control a copy of the full schema, generated using
SchemaPrinter. The purpose of this file is to act as a "schema lock" file that we can use to compare new changes against.We have a utility that uses
SchemaDiffthat developers can run to see if their changes contain breaking changes to the schema. This utility also regenerates an updated copy of the schema lock file if there are no breaking changes or the developer has indicated that breaking changes are ok.In our CI, we then compare the generated schema against the committed schema lock file to make sure the files are identical.
If the diff/lock file generation tool is run on Windows, the generated file from
SchemaPrinteris different if the schema contains multi-line descriptions.For now, we are hacking around it by using a regex search and replace to strip the weird carriage returns and extra line that appears after the opening
""".bbakerman commentedon Oct 6, 2022
The challenge we would have it testing any changes - we dont have easy access to Windows machines with the IDEA etc.. to develop a fix
ajkerr commentedon Oct 6, 2022
I'm in the same boat, unfortunately. Feel free to close this out. If I have some spare time to investigate with a Windows VM I'll try to run things through a debugger to fine the source of these carriage returns, and if I get anywhere, I can reopen with more information (or submit a pull request).
miklcct commentedon Nov 6, 2024
Please reopen.