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

Sort exception when file not writable #49

Open
lowell80 opened this issue Mar 28, 2019 · 2 comments
Open

Sort exception when file not writable #49

lowell80 opened this issue Mar 28, 2019 · 2 comments
Assignees
Labels
bug Something isn't working (Confirmed) good first issue Good for newcomers

Comments

@lowell80
Copy link
Member

The problem

Unandled exception if ksconf sort -i runs against a file that can't be updated.

Environment

  • Ksconf version: 0.7.2
  • OS & version used: Amazon Linux
  • Python version: 2.7
  • Installed via: pip via pre-commit

Details

$ ksconf --version
 _                         __
| |                       / _|
| | _____  ___ ___  _ __ | |_
| |/ / __|/ __/ _ \| '_ \|  _|
|   <\__ \ (_| (_) | | | | |
|_|\_\___/\___\___/|_| |_|_|

ksconf 0.7.2  (Build 341)
Python: 2.7.14  (/usr/bin/python2)
Git SHA1 c1923770 committed on 2019-03-22
Installed at: /usr/lib/python2.7/site-packages/ksconf
Written by Lowell Alleman <lowell@kintyre.co>.
Copyright (c) 2019 Kintyre Solutions, Inc, all rights reserved.
Licensed under Apache Public License v2

  kintyre_splunk_conf  (0.7.2)

    Commands:
      check           (stable)    OK
      combine         (beta)      OK
      diff            (stable)    OK
      filter          (alpha)     OK
      merge           (stable)    OK
      minimize        (beta)      OK
      promote         (beta)      OK
      rest-export     (beta)      OK
      rest-publish    (alpha)     OK
      snapshot        (alpha)     OK
      sort            (stable)    OK
      unarchive       (beta)      OK

Example Traceback:

Traceback (most recent call last):
  File "/opt/splunk/.cache/pre-commit/repo35FeDP/py_env-python2/bin/end-of-file-fixer", line 10, in <module>
    sys.exit(end_of_file_fixer())
  File "/opt/splunk/.cache/pre-commit/repo35FeDP/py_env-python2/lib/python2.7/site-packages/pre_commit_hooks/end_of_file_fixer.py", line 58, in end_of_file_fixer
    with open(filename, 'rb+') as file_obj:
IOError: [Errno 13] Permission denied: 'MYORG_props/default/app.conf'

Steps To Reproduce Issue

  1. Make file read-only
  2. Run ksconf sort -i on it.
@lowell80
Copy link
Member Author

Workaround:

find -name '*.conf' -o -name '*.meta' | xargs chmod +w

@lowell80 lowell80 added the bug Something isn't working (Confirmed) label May 31, 2019
@lowell80 lowell80 added the good first issue Good for newcomers label Jun 20, 2019
@lowell80
Copy link
Member Author

Desired behavior:

  1. IOError should be trapped and not handled as an unhandled exception. The error should be written to stderr; and if multiple inputs files were given, it should continue with the others.
  2. This error should be classified as an "Error" and reported as such in the output summary screen. (In other words, it should be listed alongside of files that were modified or unchanged.)
  3. We must ensure that exit code is non-0 when an errors occurs. (Create a new exit code, if none of them currently fit). This is critical for pre-commit and other scripting uses of ksconf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working (Confirmed) good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants