Certain configurations of logger fails execution with `AttributeError: 'LogRecord' object has no attribute 'attachment'`
dagansandler opened this issue · 0 comments
Describe the bug
Under some configurations, test execution may fail with the following error:
AttributeError: 'LogRecord' object has no attribute 'attachment'
This is caused by RPLogHandler.emit
calling getattr(record, 'attachment')
.
Normally, when the logger is configured correctly, this causes no problem because RP patches the logger properly. However, under some conditions, logger initialization could happen before the logger is patched by rp, which then leads to this bug.
Unfortunately I don't have a simple reproduction code for this issue, I will attach it if I can isolate this.
In my opinion, this shouldn't fail the test execution completely.
I noticed that in a previous version, this code was part of reportportal pytest plugin, where the call to get the attachment attribute was done in a safer manner:
attachment=record.__dict__.get('attachment', None)
https://github.com/reportportal/agent-python-pytest/blob/def2fa06d79256577ea568b431f6e0f8b497c276/pytest_reportportal/rp_logging.py#L148
Seems like when these classes were moved to the client, this bug may have been introduced, specifically in this commit 0664393
Expected behavior
Logger should fail silently or with some warning, but shouldn't prevent tests from running.
Actual behavior
Tests are failing due to rp logger misconfiguration
Package versions
Using:
- reportportal pytest plugin 5.1.1
- reportportal client 5.2.2
Additional context