Skip to content
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

Various problems with cruise-config encoding on Windows #10895

Open
cinex-ru opened this issue Oct 5, 2022 · 3 comments · May be fixed by #10900
Open

Various problems with cruise-config encoding on Windows #10895

cinex-ru opened this issue Oct 5, 2022 · 3 comments · May be fixed by #10900

Comments

@cinex-ru
Copy link

cinex-ru commented Oct 5, 2022

Issue Type
  • Bug Report
Summary

Various problems with cruise-config encoding

Basic environment details
"java.runtime.version": "17.0.4+8"
"os.arch": "amd64",
"os.name": "Windows 10",
"os.version": "10.0",
"Go Server Version": "22.2.0 (14697-4bdda4e0d769e66da651926c7066979740bd7ae7)"
"browser": "Chrome 105.0.5195.127"
Steps to Reproduce

Updating pipeline:

  1. Add Custom Command task
  2. Edit command to '開始'
  3. Save task
  4. Check cruise-config.xml tasks section

Editing config xml Part One

  1. Go Admin / Config XML
  2. Press Edit button
  3. Edit command in tasks section
              <exec command="開始">
                <arg />
                <runif status="passed" />
              </exec>
  1. Try to save
  2. Check new command

Editing config xml Part Two

  1. Go Admin / Config XML
  2. Press Edit button
  3. Edit command in tasks section
              <exec command="Команда">
                <arg />
                <runif status="passed" />
              </exec>
  1. Try to save
cinex-ru added a commit to cinex-ru/gocd that referenced this issue Oct 6, 2022
@chadlwilson
Copy link
Member

chadlwilson commented Oct 6, 2022

I haven't validated, but is it possible that a workaround for this may be to set -Dfile.encoding=UTF-8 in the config\wrapper-properties.conf of your installation? In theory the config files should be read, written and declared as UTF-8 everywhere but I suppose it's possible something might have been missed somewhere along the line or a regression introduced on Windows.

The last line here does look a bit dubious

public String configAsXml(CruiseConfig config, boolean skipPreprocessingAndValidation) throws Exception {
LOGGER.debug("[Config Save] === Converting config to XML");
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
magicalGoConfigXmlWriter.write(config, outputStream, skipPreprocessingAndValidation);
LOGGER.debug("[Config Save] === Done converting config to XML");
return outputStream.toString();
}

As does

try (ByteArrayOutputStream output = new ByteArrayOutputStream(32 * 1024)) {
XmlUtils.writeXml(element, output);
return output.toString();
} catch (IOException e) {
throw bomb("Unable to write xml to String");
}

@chadlwilson
Copy link
Member

chadlwilson commented Oct 23, 2022

FWIW, setting-Dfile.encoding=UTF-8 isn't enough. You need to set the wrapper specific property of either wrapper.jvm.encoding=UTF-8 or wrapper.lang.windows.encoding=UTF-8. There's some weird wrapper behaviour at https://wrapper.tanukisoftware.com/doc/english/props-lang.html#platform

Example of error you can get on Admin when the default encoding is something like cp2252 and you try to save something

image

@chadlwilson chadlwilson linked a pull request Oct 23, 2022 that will close this issue
@chadlwilson chadlwilson changed the title Various problems with cruise-config encoding Various problems with cruise-config encoding on Windows Mar 6, 2023
@stale
Copy link

stale bot commented Jun 17, 2023

This issue has been automatically marked as stale because it has not had activity in the last 90 days.
If you can still reproduce this error on the master branch using local development environment or on the latest GoCD Release, please reply with all of the information you have about it in order to keep the issue open.
Thank you for all your contributions.

@stale stale bot added the stale label Jun 17, 2023
@stale stale bot closed this as completed Aug 12, 2023
@chadlwilson chadlwilson reopened this Aug 13, 2023
@chadlwilson chadlwilson added no stalebot Don't mark this stale. and removed stale labels Aug 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants