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

Certain configurations of logger fails execution with AttributeError: 'LogRecord' object has no attribute 'attachment' #184

Closed
dagansandler opened this issue Jun 20, 2022 · 0 comments
Labels

Comments

@dagansandler
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant