You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by hu...@apache.org on 2020/09/10 10:06:24 UTC

[incubator-ponymail-foal] branch master updated (100d9d4 -> db6c0ad)

This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git.


    from 100d9d4  spit out why exactly this failed.
     new 98633b2  Allow for traceback to be printed to the journal (stderr) instead of to the client
     new db6c0ad  elaborate a bit on how to grep... :)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 INSTALL.md                      | 12 +++++++++++-
 server/main.py                  | 17 ++++++++++++++---
 server/plugins/configuration.py |  4 ++++
 tools/setup.py                  |  1 +
 4 files changed, 30 insertions(+), 4 deletions(-)


[incubator-ponymail-foal] 01/02: Allow for traceback to be printed to the journal (stderr) instead of to the client

Posted by hu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git

commit 98633b28fb3495543067e536b28bdab088f6f470
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Thu Sep 10 12:03:57 2020 +0200

    Allow for traceback to be printed to the journal (stderr) instead of to the client
---
 INSTALL.md                      |  8 +++++++-
 server/main.py                  | 17 ++++++++++++++---
 server/plugins/configuration.py |  4 ++++
 tools/setup.py                  |  1 +
 4 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/INSTALL.md b/INSTALL.md
index 46478b2..51cbe7c 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -127,4 +127,10 @@ separating each entry with a single space:
 - to allow email for all lists at any subdomain under mydomain.tld, you should add `*.mydomain.tld`
 
 Only users logged in via authoritative OAuth will be able to compose replies via the
-web interface.
\ No newline at end of file
+web interface.
+
+## Hiding tracebacks from users
+By default, API errors will include a full traceback for debugging purposes. If you wish to 
+instead have this be printed to the system journal (`stderr`), you can set the `traceback`
+option to `false` in `server/ponymail.yaml`. This will instead print an error ID to the user, 
+corresponding to a traceback in stderr.
diff --git a/server/main.py b/server/main.py
index 45c64ec..22161ed 100644
--- a/server/main.py
+++ b/server/main.py
@@ -27,6 +27,7 @@ import traceback
 
 import aiohttp.web
 import yaml
+import uuid
 
 import plugins.background
 import plugins.configuration
@@ -132,9 +133,19 @@ class Server(plugins.server.BaseServer):
                 err = "\n".join(
                     traceback.format_exception(exc_type, exc_value, exc_traceback)
                 )
-                return aiohttp.web.Response(
-                    headers=headers, status=500, text="API error occurred: " + err
-                )
+                if self.config.ui.traceback:
+                    return aiohttp.web.Response(
+                        headers=headers, status=500, text="API error occurred: " + err
+                    )
+                else:
+                    eid = str(uuid.uuid4())[:18]
+                    sys.stderr.write("API Endpoint %s got into trouble (%s): \n" % (request.path, eid))
+                    for line in err.split("\n"):
+                        sys.stderr.write("%s: %s\n" % (eid, line))
+                    return aiohttp.web.Response(
+                        headers=headers, status=500, text="API error occurred. The application journal will have "
+                                                          "information. Error ID: %s" % eid
+                    )
         else:
             return aiohttp.web.Response(
                 headers=headers, status=404, text="API Endpoint not found!"
diff --git a/server/plugins/configuration.py b/server/plugins/configuration.py
index 7ab746b..4546a59 100644
--- a/server/plugins/configuration.py
+++ b/server/plugins/configuration.py
@@ -18,11 +18,15 @@ class UIConfig:
     wordcloud:      bool
     mailhost:       str
     sender_domains: str
+    traceback:      bool
 
     def __init__(self, subyaml: dict):
         self.wordcloud = bool(subyaml.get('wordcloud', False))
         self.mailhost = subyaml.get('mailhost', '')  # Default to nothing (disabled)
         self.sender_domains = subyaml.get('sender_domains', '')  # Default to nothing (disabled)
+        # Default to spitting out traceback to web clients
+        # Set to false in yaml to redirect to stderr instead.
+        self.traceback = subyaml.get('traceback', True)
 
 
 class OAuthConfig:
diff --git a/tools/setup.py b/tools/setup.py
index bcc8ccc..cbbadc9 100755
--- a/tools/setup.py
+++ b/tools/setup.py
@@ -451,6 +451,7 @@ ui:
   wordcloud:       %s
   mailhost:        %s
   sender_domains:  %s
+  traceback:       true
 
 tasks:
   refresh_rate:  150     # Background indexer run interval, in seconds


[incubator-ponymail-foal] 02/02: elaborate a bit on how to grep... :)

Posted by hu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git

commit db6c0ada248a379a0db50948781748b1545e69ae
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Thu Sep 10 12:06:11 2020 +0200

    elaborate a bit on how to grep... :)
---
 INSTALL.md | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/INSTALL.md b/INSTALL.md
index 51cbe7c..9193aff 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -133,4 +133,8 @@ web interface.
 By default, API errors will include a full traceback for debugging purposes. If you wish to 
 instead have this be printed to the system journal (`stderr`), you can set the `traceback`
 option to `false` in `server/ponymail.yaml`. This will instead print an error ID to the user, 
-corresponding to a traceback in stderr.
+corresponding to a traceback in stderr. 
+
+If the error ID is, for instance, `a06f7d4b-3a82-4ecf`, you can find the corresponding traceback
+by grepping your programs output. If you are running Foal as a systemd service, you could find 
+the traceback with: `journalctl --no-pager -u yourservicename | grep a06f7d4b-3a82-4ecf`