#2150 selinux_setup.py KeyError: 'indent' in error handling code
Closed: migrated 3 years ago by dmoluguw. Opened 8 years ago by cheimes.

Today I ran into a similar issue as described in #1185. The error reporting code in selinux_setup.py is missing an indent argument.

Traceback (most recent call last):
  File "/usr/lib64/python2.7/logging/__init__.py", line 859, in emit
    msg = self.format(record)                 
  File "/usr/lib64/python2.7/logging/__init__.py", line 732, in format
    return fmt.format(record)                 
  File "/usr/lib64/python2.7/logging/__init__.py", line 474, in format
    s = self._fmt % record.__dict__        
KeyError: 'indent'                  
Logged from file selinux_setup.py, line 130

I'd like to solve the problem in a more generic way. indent is a custom argument of Dogtag's Python installer and not part of the common logging code. There might be more places with a missing indent argument, too. We can easily add a filter that ensures the existence of an indent arg:

class IndentAdder(logging.Filter):
    def filter(self, record):
        if isinstance(record.args, dict):
            record.args.setdefault('indent', '')
        record.__dict__.setdefault('indent', '')
        return True

...
logger.addFilter(IndentAdder())

Yes, filters are allowed to modify the log record.


Per CS/DS Triage Meeting of 03/22/2016: 10.3

Metadata Update from @cheimes:
- Issue assigned to cheimes
- Issue set to the milestone: UNTRIAGED

7 years ago

Dogtag PKI is moving from Pagure issues to GitHub issues. This means that existing or new
issues will be reported and tracked through Dogtag PKI's GitHub Issue tracker.

This issue has been cloned to GitHub and is available here:
https://github.com/dogtagpki/pki/issues/2335

If you want to receive further updates on the issue, please navigate to the
GitHub issue and click on Subscribe button.

Thank you for understanding, and we apologize for any inconvenience.

Metadata Update from @dmoluguw:
- Issue close_status updated to: migrated
- Issue status updated to: Closed (was: Open)

3 years ago

Login to comment on this ticket.

Metadata