Skip to content

Build: solve problem with sanitized output #9257

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

Merged
merged 3 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions readthedocs/doc_builder/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def sanitize_output(self, output):
# https://code.djangoproject.com/ticket/28201
sanitized = sanitized.replace('\x00', '')
except (TypeError, AttributeError):
sanitized = None
sanitized = ""

# Chunk the output data to be less than ``DATA_UPLOAD_MAX_MEMORY_SIZE``
output_length = len(output) if output else 0
Expand Down Expand Up @@ -317,8 +317,8 @@ def run(self):
cmd_stdout = out
# Docker returns None when there's no stderr/stdout
# so we need to convert that to a string.
Copy link
Member

@stsewd stsewd May 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment doesn't make sense anymore

self.output = self.sanitize_output(cmd_stdout or "")
self.error = self.sanitize_output(cmd_stderr or "")
self.output = self.sanitize_output(cmd_stdout)
self.error = self.sanitize_output(cmd_stderr)
cmd_ret = client.exec_inspect(exec_id=exec_cmd['Id'])
self.exit_code = cmd_ret['ExitCode']

Expand Down
2 changes: 1 addition & 1 deletion readthedocs/rtd_tests/tests/test_doc_building.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def test_error_output(self):
cmd = BuildCommand(['/bin/bash', '-c', 'echo -n FOOBAR 1>&2'])
cmd.run()
self.assertEqual(cmd.output, 'FOOBAR')
self.assertIsNone(cmd.error)
self.assertEqual(cmd.error, "")

def test_sanitize_output(self):
cmd = BuildCommand(['/bin/bash', '-c', 'echo'])
Expand Down