SATOSA icon indicating copy to clipboard operation
SATOSA copied to clipboard

Clean error reporting

Open rhoerbe opened this issue 8 years ago • 4 comments

If an exception is well understood and reported, there is no point in adding a stacktrace. E.g.: currently a saml2.s_utils.UnknownSystemEntity exception will result in a stacktrace (and disguise it as an "unknow error", btw). As the reason is a missing entry in metadata, a concise "configuration error: unknown system entity https://sp.example.org/sp" is suffient. Therefore I propose to add in base:run

        except UnknownSystemEntity as err:
            satosa_logging(logger, logging.ERROR,
                           "configuration error: unknown system entity " + str(err),
                           context.state, exc_info=False)
            raise

However, proxy_server:run will handle the raised exception as a general Exception and print the stack trace. A possible solution would be to define a generic SatosaAlreadyReportedException that will silentce the traceback by adding the second line in following snippet from proxy_server.

        except (Exception, SatosaAlreadyReportedException) as err:
            if type(err) != SatosaAlreadyReportedException:        
                logger.exception("%s" % err)
            if debug:
                raise
            resp = ServiceError("%s" % err)
            return resp(environ, start_response)

What do people think?

rhoerbe avatar Aug 18 '17 16:08 rhoerbe

Further to this issue the current scheme will create an inappropriate Status message. A saml2.response.StatusInvalidNameidPolicy exception will create a urn:oasis:names:tc:SAML:2.0:status:AuthnFailed message, whereas urn:oasis:names:tc:SAML:2.0:status:InvalidNameIDPolicy would be correct.

rhoerbe avatar Aug 20 '17 13:08 rhoerbe

More: The exception saml2.validate.ToEarly thrown when processing the response in the backend is wrapped in "satosa.exception.SATOSAAuthenticationError: Failed to parse authn request". Expected behavior: only the original exception should be logged, the traceback is not helpful.

rhoerbe avatar Aug 30 '17 17:08 rhoerbe

Related to #146

c00kiemon5ter avatar Aug 31 '17 15:08 c00kiemon5ter

Even tho I have entry in the metadata I am still getting the unknown system entity error. Please help

amanmd672 avatar Jul 16 '20 21:07 amanmd672