Skip to content

Error when recording commands with NULL (0x00) in the output #3900

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

Closed
humitos opened this issue Apr 4, 2018 · 12 comments · Fixed by #4591
Closed

Error when recording commands with NULL (0x00) in the output #3900

humitos opened this issue Apr 4, 2018 · 12 comments · Fixed by #4591
Assignees
Labels
Accepted Accepted issue on our roadmap Bug A bug Needed: replication Bug replication is required

Comments

@humitos
Copy link
Member

humitos commented Apr 4, 2018

I found that there are some sphinx-build commands that use NULL (0x00) character in the output and that output is used to hit the API endpoint https://readthedocs.org/api/v2/command/

This endpoint fails because

ValueError('A string literal cannot contain NUL (0x00) characters.',)

We do some sanitization at https://github.com/rtfd/readthedocs.org/blob/40a4ff3337812621d3c26a0d93d783e097da5ad5/readthedocs/doc_builder/environments.py#L160-L164

but we probably need more than that.

Related Sentry issues:

This is producing the Builds to fail with an unexpected error.

@humitos humitos added the Bug A bug label Apr 4, 2018
@humitos humitos added this to the Build stability milestone Apr 4, 2018
@stsewd
Copy link
Member

stsewd commented Apr 13, 2018

I'm not sure if understand the issue, but I can't replicate with this

resp = client.post(
    '/api/v2/command/',
    {
        'build': build['id'],
        'command': 'echo test',
        'output': 'f\0o',
        'exit_code': 0,
        'start_time': str(now - datetime.timedelta(seconds=5)),
        'end_time': str(now),
    },
    format='json',
)

@RichardLitt RichardLitt added the Needed: replication Bug replication is required label Apr 13, 2018
@humitos
Copy link
Member Author

humitos commented Aug 19, 2018

I can't reproduce this locally, even knowing that in production fails with project climt. I think it worth a test with the same database we have in production: Postgres 9.3

@humitos humitos self-assigned this Aug 19, 2018
@humitos humitos added the Accepted Accepted issue on our roadmap label Aug 19, 2018
@humitos
Copy link
Member Author

humitos commented Aug 19, 2018

This is the problem,

In [31]: for char in bc.output:
    ...:     if char == '\x00':
    ...:         print(char)
    ...:         print(bc.output.index(char))


In [30]: bc.output[7700:8150]
Out[30]: 'lock ending on line 68\nSpecify :okexcept: as an option in the ipython:: block to suppress this message\n\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00----------------'

@JoyMonteiro
Copy link

is there anything that can be done from my end? Can I modify something in my docs or build process to
prevent these nulls from appearing in the output?

We just did a major refactor and I would like to update the docs to reflect it.

@JoyMonteiro
Copy link

I tried re-building my docs, and it worked just fine, thanks! However, RTD still reports that
the build errored. Not sure what it means since the the docs are live!

https://readthedocs.org/projects/climt/builds/7686064/

@stsewd
Copy link
Member

stsewd commented Aug 24, 2018

The PR was merged, but the code wasn't deployed yet, probably it failed in the pdf generation step

@JoyMonteiro
Copy link

I see, thanks. How long does this process normally take? I'm in no hurry since the HTML docs are live, but just curious.

@stsewd
Copy link
Member

stsewd commented Aug 24, 2018

We do not have a schedule, but I think a deployment is planned for next week.

@JoyMonteiro
Copy link

Great, thanks!

@humitos
Copy link
Member Author

humitos commented Aug 27, 2018

This is already fixed and merged. I will deployed in the next days, so @JoyMonteiro you will just need to re-build your version once it's deployed.

@JoyMonteiro
Copy link

Thanks, @humitos!

@humitos
Copy link
Member Author

humitos commented Aug 30, 2018

I'm reopening this issue because after yesterday's deploy it's still happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Accepted issue on our roadmap Bug A bug Needed: replication Bug replication is required
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants