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

Error: "Cannot read properties of null (reading 'rules')" #78

Closed
luciansmith opened this issue Mar 29, 2023 · 6 comments · Fixed by #80
Closed

Error: "Cannot read properties of null (reading 'rules')" #78

luciansmith opened this issue Mar 29, 2023 · 6 comments · Fixed by #80

Comments

@luciansmith
Copy link

When running the latest svglint on ubuntu, it's failing to do any linting; I assume the problem stems from some recent update to svglint or one of its dependencies.

Here's what I get when trying it:

(x) Failed to lint file /home/lpsmith/biomodels-qc/tests/fixtures/BIOMD0000000692/BIOMD0000000692.svg 
 TypeError: Cannot read properties of null (reading 'rules')
    at normalizeConfig (file:///usr/local/lib/node_modules/svglint/src/svglint.js:103:70)
    at lint (file:///usr/local/lib/node_modules/svglint/src/svglint.js:124:24)
    at Object.lintFile (file:///usr/local/lib/node_modules/svglint/src/svglint.js:152:16)

This happens regardless of the file I point it at, whether an actual SVG file or otherwise.

luciansmith added a commit to biosimulations/biomodels-qc that referenced this issue Mar 29, 2023
'svglint' is just broken on ubuntu at the moment.  Uncomment when simple-icons/svglint#78 is addressed.
luciansmith added a commit to luciansmith/svglint that referenced this issue Mar 29, 2023
Possible fix for simple-icons#78.  Not sure I've used 'hasOwnProperty' correctly, but this at least works for me when there is no user config.
@ericcornelissen
Copy link
Contributor

When running the latest svglint on ubuntu, it's failing to do any linting; [...]

Just to double check, latest being v2.3.0 (you can double check this by running npm ls svglint in your project)?

[...] I assume the problem stems from some recent update to svglint or one of its dependencies.

Does that imply it did work for you at some point in the past? If so, what version of svglint did work for you?

Here's what I get when trying it:

(x) Failed to lint file /home/lpsmith/biomodels-qc/tests/fixtures/BIOMD0000000692/BIOMD0000000692.svg 
 TypeError: Cannot read properties of null (reading 'rules')
    at normalizeConfig (file:///usr/local/lib/node_modules/svglint/src/svglint.js:103:70)
    at lint (file:///usr/local/lib/node_modules/svglint/src/svglint.js:124:24)
    at Object.lintFile (file:///usr/local/lib/node_modules/svglint/src/svglint.js:152:16)

This happens regardless of the file I point it at, whether an actual SVG file or otherwise.

It seems something's going wrong with your configuration file. Could you share the configuration file (or a representative sample) or the whole project you're working with if it's publicly available?

@luciansmith
Copy link
Author

There's no configuration file at all. This is being run as part of a github action, where svglint is installed from npm, and then immediately used. I'm not sure which version it was when it worked, but I know it used to work, and now fails--this could be due to any number of things, unfortunately, up to and including ubuntu itself being updated.

Here's the 'live' result of svglint failing:

https://github.com/biosimulations/biomodels-qc/actions/runs/4516731122/jobs/7955350793

The test is just 'run svglint on a png file'. From when it used to work:

https://github.com/biosimulations/biomodels-qc/actions/runs/2150934692/jobs/3143682354

The workflow file is:

https://github.com/biosimulations/biomodels-qc/blob/dev/.github/workflows/ci.yml

The python code that calls the function is just:

def validate_svg_file(filename):
    """ Determine if a SVG file is valid

    Args:
        filename (:obj:`str`): path to SVG file

    Returns:
        :obj:`tuple`:

            * nested :obj:`list` of :obj:`str`: nested list of errors
            * nested :obj:`list` of :obj:`str`: nested list of warnings
    """
    result = subprocess.run(['svglint', filename], check=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    if result.returncode == 0:
        return [], []
    else:
        return [[result.stderr.decode()]], []

Investigating, I ran the same commands on my VirtualBox Ubuntu machine, and got the 'failed to lint file' error above.

Results from 'npm ls svglint':

lpsmith@lpsmith-VirtualBox:~/biomodels-qc$ npm ls svglint

/home/lpsmith/biomodels-qc

└── (empty)

lpsmith@lpsmith-VirtualBox:~/biomodels-qc$ svglint --version

2.3.0

#79 shows a fix that works for me (with no config file), though it fails the automatic tests here.

Thanks for looking into this!

@ericcornelissen
Copy link
Contributor

There's no configuration file at all. This is being run as part of a github action, where svglint is installed from npm, and then immediately used. I'm not sure which version it was when it worked, but I know it used to work, and now fails--this could be due to any number of things, unfortunately, up to and including ubuntu itself being updated. [...]

Thanks for elaborating. Based on the "no-configuration-file-at-all" I was able to reproduce the issue. I was also able to determine that the issue first appeared in v2.2.0.

If you need a quick solution for your CI, you can change this line as follows:

-         run: npm install -g svglint
+         run: npm install -g [email protected]

Results from 'npm ls svglint': [...]

Thanks for the details. the npm ls command only works if you have a npm manifest so it makes sense it came back empty. Thanks for sharing the svglint --version output, probably should've just asked for that 😅

#79 shows a fix that works for me (with no config file), though it fails the automatic tests here.

I saw, thanks for jumping in with a fix! Just wanted to understand the problem better before looking at that - will try to look at this as soon as possible.

@luciansmith
Copy link
Author

Thanks so much! An immediate workaround and the promise of a fix is great.

@github-actions
Copy link

github-actions bot commented Apr 7, 2023

🎉 This issue has been resolved in version 2.3.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@luciansmith
Copy link
Author

Works for me! Thanks again.

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