Certain configurations of logger fails execution with AttributeError: 'LogRecord' object has no attribute 'attachment'
#184
Labels
AttributeError: 'LogRecord' object has no attribute 'attachment'
#184
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
callinggetattr(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#L148Seems 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:
Additional context
The text was updated successfully, but these errors were encountered: