OctoPrint / OctoPrint-FileCheck

Checks for common issues in uploaded files
GNU Affero General Public License v3.0
8 stars 2 forks source link

grep: Invalid content of \{\} #2

Closed Stretch96 closed 3 years ago

Stretch96 commented 3 years ago

What were you doing?

Restarted OctoPrint after upgrading to 1.5.3

What happened?

Noticed an odd line in the logs:

Jan 28 21:44:46 raspberrypi octoprint[1111]: grep: Invalid content of \{\}

OctoPrint still runs fine, appears to be caught as just a warning, just raising as an issue 👍

github-actions[bot] commented 3 years ago

Hi @Stretch96,

it looks like there is some information missing from your bug report that will be needed in order to solve the problem. Read the Contribution Guidelines which will provide you with a template to fully fill out here so that your bug report is ready to be investigated (I promise I'll go away then too!).

If you did not intend to report a bug but wanted to request a feature or brain storm about some kind of development, please take special note of the title format to use as described in the Contribution Guidelines.

Please do not abuse the bug tracker as a support forum - that can be found at community.octoprint.org. Go there for any kind of issues with network connectivity, webcam functionality, printer detection or any other kind of such support requests or general questions.

Also make sure you are at the right place - this is the bug tracker of the official version of OctoPrint, not the Raspberry Pi image OctoPi nor any unbundled third party OctoPrint plugins or unofficial versions. Make sure too that you have read through the Frequently Asked Questions and searched the existing tickets for your problem - try multiple search terms please.

I'm marking this one now as needing some more information. Please understand that if you do not provide that information within the next two weeks I'll close this ticket so it doesn't clutter the bug tracker. This is nothing personal, it's needed to keep this project manageable. Please just be considerate and help the maintainers solve this problem quickly by following the guidelines linked above. Remember, the less time the devs have to spend running after information on tickets, the more time they have to actually solve problems and add awesome new features. Thank you!

I'm just a bot 🤖, not a human being, so don't expect any replies from me :) Your ticket is read by humans too, I'm just not one of them.

cp2004 commented 3 years ago

Off the top of my head, I don't know of anywhere that is using grep, I have a vague recollection of gcode analysis using it, but given how large OctoPrint is we are really going to need more info to track that down - please look at it our way, where would you start looking in the codebase with a single line from the log? The contribution guidelines have lots of info, so you know what we are looking for 🙂

Stretch96 commented 3 years ago

Indeed, I thought I'd raise it as an issue for now

I'll try dig into why it's happening, just in case it becomes a bigger issue in future

I was quite surprised that there was a warning from grep ...

Stretch96 commented 3 years ago

I've manage to reproduce the issue on a blank Pi:

$ git clone git@github.com:OctoPrint/OctoPrint.git
$ cd OctoPrint
$ pip install .

## /etc/systemd/system/octoprint.service
[Unit]
Description=Octoprint Server
After=network.target

[Service]
User=pi
Environment=PORT=5000
Restart=on-failure
ExecStart=/home/pi/.local/bin/octoprint serve --port=${PORT}

[Install]
WantedBy=multi-user.target

$ sudo systemctl daemon-reload
$ service octoprint start

Upload a file via Octoprint UI

$ sudo service octoprint restart

The log appears in syslog again:

$ sudo less /var/log/syslog
[...]
Jan 29 00:48:07 homepi-04 octoprint[2852]: 2021-01-29 00:48:07,552 - octoprint.filemanager.analysis - INFO - Invoking analysis command: /usr/
bin/python3 -m octoprint analysis gcode --speed-x=6000 --speed-y=6000 --max-t=10 --throttle=0.0 --throttle-lines=100 /home/pi/.octoprint/u
ploads/Lego_bricks.gcode
Jan 29 00:48:07 homepi-04 octoprint[2852]: grep: Invalid content of \{\}
[...]

I wonder if it is the gcode file that Octoprint doesn't like ... I can provide it if needed

Stretch96 commented 3 years ago

This is the only mention of grep in the codebase:

## ./versioneer.py
def get_keywords():
    """Get the keywords needed to look up the version information."""
    # these strings will be replaced by git during git-archive.
    # setup.py/versioneer.py will grep for the variable names, so they must
    # each be defined on a line of their own. _version.py will just call
    # get_keywords().
    git_refnames = "%(DOLLAR)sFormat:%%d%(DOLLAR)s"
    git_full = "%(DOLLAR)sFormat:%%H%(DOLLAR)s"
    keywords = {"refnames": git_refnames, "full": git_full}
    return keywords

May be relevant 🤷

foosel commented 3 years ago

It's probably rather the pulled in OctoPrint-FileCheck plugin, if it happens on a file upload.

https://github.com/OctoPrint/OctoPrint-FileCheck/blob/master/octoprint_file_check/__init__.py#L76

I see absolutely no way how that can end up with an empty pattern though 🤔

So please, let's do the needful here. I need octoprint.log, a file with which to reproduce and also a test in safe mode to rule out this is a third party plugin and not filecheck after all. In short, what the template asked you to provide ;)

Stretch96 commented 3 years ago

Ah yep, apologies @foosel - I'll recreate the issue with the logs as I should have 😬

I did just try reproduce it on the same Pi, but it's no longer producing the warning 🤔 (Maybe that I've tainted it with other plugins or packages ... even with --safe)

I'll dig further and provide what is needed to hopefully fix the issue 👍

Stretch96 commented 3 years ago

Hi @foosel, I've recreated the issue, and now have logs available 👍

Flashed a RaspberryPi, and installed Octoprint

The 'grep' error still only occurs in the syslog weirdly ...

Full 'history' log: https://gist.github.com/Stretch96/461f94c2e325e3893e5a3080f6a594c9#file-1-history octoprint.log: https://gist.github.com/Stretch96/461f94c2e325e3893e5a3080f6a594c9#file-2-octoprint-log syslog: https://gist.github.com/Stretch96/461f94c2e325e3893e5a3080f6a594c9#file-3-syslog

github-actions[bot] commented 3 years ago

Since apparently some of the required information is still missing, this will be closed now, sorry. Feel free to request a reopen of this or create a new issue once you can provide all required information.

This is nothing personal. Thank you for your collaboration.

foosel commented 3 years ago

The good news is I have been able to reproduce it now. The info that it only shows up in syslog was crucial here. The bad news is that I still have no idea at all why this is happening. However, I'm moving this over to the FileCheck plugin since that is most certainly where this is happening.

cp2004 commented 3 years ago

In case it is useful, I experimented with this the other day - still couldn't work out why it failed, but I had the same message in the stdout from running octoprint serve on my Pi (through remote debug).

pi@octopi:~ $ grep -q '^[^;]*\\{travel_speed\\}' '/home/pi/.octoprint/uploads/xyzCalibration_cube.gcode'
pi@octopi:~ $ grep -q '^[^;]*\{travel_speed\}' '/home/pi/.octoprint/uploads/xyzCalibration_cube.gcode'
grep: Invalid content of \{\}

Something's up with the escaping somewhere

foosel commented 3 years ago

Yeah, I figured it out. Grep by default doesn't need those brackets escaped because it runs in simple regex mode (where those don't have a special meaning). Adding -E solves it however. I'm prepping an update.

The sad thing is that for some reason my local grep on my Win10 box doesn't have this issue, since it only ever ended up in syslog I didn't notice it while testing on the Pi, and thus this whole check probably never so far ran in the field 🤦‍♀️

Ah well... adding fix & logging.

foosel commented 3 years ago

Fixed in 2021.2.23

Stretch96 commented 3 years ago

Awesome, thanks @foosel @cp2004 for fixing 😬