mirror of
https://github.com/langgenius/dify-official-plugins.git
synced 2026-07-21 17:45:23 -04:00
Avoid using print() for debugging to prevent sensitive information from leaking via container logs #628
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kurokobo on GitHub (Sep 6, 2025).
Self Checks
Dify version
2.0.0-beta.1
Plugin version
Any
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
✔️ Error log
Credentials are there in plain text.
@kurokobo commented on GitHub (Sep 6, 2025):
@crazywoola @Yeuoly
It seems that some plugins in this repository use
print()for debugging purposes or error output.Standard output from
print()is passed to the Plugin Daemon, which tries to parse it as JSON. However, mostprint()outputs are not JSON strings, so this leads to parsing errors, which are then output as errors in the logs of the Plugin Daemon container.Because of this, information intended only for debugging may leak into the logs.
For example, the S3 data source plugin outputs credentials in plain text, as above screenshot, since it has
print(credentials).https://github.com/langgenius/dify-official-plugins/blob/205d2fb694c9cda6324c0fc66c9c20c05f59b2ae/datasources/aws_s3_storage/datasources/aws_s3_storage.py#L25
In the case of the Google Drive data source plugin, file information is outputted. It
prints raw api response.https://github.com/langgenius/dify-official-plugins/blob/205d2fb694c9cda6324c0fc66c9c20c05f59b2ae/datasources/google_drive/datasources/google_drive.py#L70
While errors caused by
print()in the Plugin Daemon do not affect the actual behavior of the plugin itself, the plugin still works as expected. That said, unnecessary errors should be suppressed, and since it could potentially lead to the leakage of sensitive information, I personally thinkprint()shouldn’t be used in principle.What do you think?
For now, I’ll open a PR for the S3 and Google Drive plugins, which I was able to test.
Since there are quite a few plugins with
print(), I’ll leave it up to you how far you want to go with it.@dosubot[bot] commented on GitHub (Sep 6, 2025):
You're absolutely right—using print() for debugging or error output in plugins is risky, especially since it can leak sensitive data like credentials and file metadata into container logs, and causes parsing errors in the Plugin Daemon logs. This is a widespread issue in the repository, and there isn't a unified logging framework or guideline in place; most plugins rely on print(), even when handling sensitive information example.
A better approach is to adopt a structured logging framework (like Python's logging module) across all plugins, with clear guidelines to avoid logging sensitive information. Some plugins, like Google Drive, partially use logging but still fall back to print(), so practices are inconsistent example.
It would be beneficial to update plugin templates and documentation to enforce best practices for logging and error output, and consider a codebase-wide refactor to replace print() with structured logging—especially in plugins that handle sensitive data. This would improve security, log quality, and operational reliability.
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

@kurokobo commented on GitHub (Sep 6, 2025):
It takes some extra effort, but if we intentionally want to output certain strings to the container logs, I think it’s better to replace everything with
loggeras described in this page (which I wrote before 😃): https://docs.dify.ai/plugin-dev-en/0222-debugging-logs@fdb02983rhy commented on GitHub (Sep 7, 2025):
Thanks for bringing this up
@dosubot[bot] commented on GitHub (Sep 23, 2025):
Hi, @kurokobo. I'm Dosu, and I'm helping the dify-official-plugins team manage their backlog and am marking this issue as stale.
Issue Summary:
Next Steps:
Thanks for your understanding and contribution!