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

2.16.1 log filter prevents logging lists #12139

Closed
4 tasks done
kbialka-eqr opened this issue Mar 1, 2024 · 4 comments · Fixed by #12151
Closed
4 tasks done

2.16.1 log filter prevents logging lists #12139

kbialka-eqr opened this issue Mar 1, 2024 · 4 comments · Fixed by #12151
Assignees
Labels
bug Something isn't working

Comments

@kbialka-eqr
Copy link

First check

  • I added a descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the Prefect documentation for this issue.
  • I checked that this issue is related to Prefect and not one of its dependencies.

Bug summary

Prior to 2.16.1 you could log lists and it appears the new logging filter feature added in #12072 now prevents that.

Reproduction

from prefect import flow, get_run_logger


@flow()
def test_log_list():

    logger = get_run_logger()
    lst_msg = ["hi", "I'm", "a", "list"]
    logger.info(lst_msg)


if __name__ == "__main__":
    test_log_list()

Error

No response

Versions

Version:             2.16.1
API version:         0.8.4
Python version:      3.10.9
Git commit:          2e3343b5
Built:               Thu, Feb 29, 2024 4:44 PM

Additional context

Works fine on 2.14.10

@kbialka-eqr kbialka-eqr added bug Something isn't working needs:triage labels Mar 1, 2024
@bjorhn
Copy link
Contributor

bjorhn commented Mar 2, 2024

I just bumped into something that likely is related. If I attempt to log a dict, Prefect crashes. This used to work in previous versions.

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/prefect/engine.py", line 863, in orchestrate_flow_run
    result = await flow_call.aresult()
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 326, in aresult
    return await asyncio.wrap_future(self.future)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 351, in _run_sync
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/prefect/orchestration/flows/load_gold.py", line 51, in default
    logger.info(dbt_cloud_logs)
  File "/usr/local/lib/python3.11/logging/__init__.py", line 1849, in info
    self.log(INFO, msg, *args, **kwargs)
  File "/usr/local/lib/python3.11/logging/__init__.py", line 1887, in log
    self.logger.log(level, msg, *args, **kwargs)
  File "/usr/local/lib/python3.11/logging/__init__.py", line 1559, in log
    self._log(level, msg, args, **kwargs)
  File "/usr/local/lib/python3.11/logging/__init__.py", line 1634, in _log
    self.handle(record)
  File "/usr/local/lib/python3.11/logging/__init__.py", line 1643, in handle
    if (not self.disabled) and self.filter(record):
                               ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/logging/__init__.py", line 830, in filter
    result = f.filter(record)
             ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/prefect/logging/filters.py", line 16, in filter
    record.msg = record.msg.replace(
                 ^^^^^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'replace'```

@nik-joseph
Copy link

Got this issue logging a requests Response objects. doesn't allow logging anything that isn't a string.

@zzstoatzz
Copy link
Contributor

hi @kbialka-eqr @bjorhn and @nik-joseph - thank you for the reports!

we have addressed this in #12151 and released 2.16.2 with this fix - sorry about that!

@bjorhn
Copy link
Contributor

bjorhn commented Mar 4, 2024

No worries, appreciate the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants