1677 return stack trace for authenticated users with specific roles#1683
1677 return stack trace for authenticated users with specific roles#1683krowvin wants to merge 13 commits into
Conversation
… behavior and keeping it consistent
|
Something to note is that it returns JSON and a stack trace in JSON is not the prettiest of things with all the \n in the JSON string. The last commit shows an alternative where we could keep both, or pick one, of the options. Putting the traces in a list split by the newline (Could probably do \n\t too) does render nicely in the browser at least and possible in a fetch/output of a downstream client. Vs |
MikeNeilson
left a comment
There was a problem hiding this comment.
Instead of using System.getProperty or System.getenv directly, integrate into the Togglz feature system.
But otherwise I don't hate it. Do want to chew on it some more, but overall seems reasonable.
|
Spoke with Mike. Lets go with stackTraceLines and remove the string. Need to fix the OpenAPI spec. Latest Schema can break if Oracle out of sync (but check). But search for FAILED all caps and first instance all caps FAILED should have your error for the other failed tests. |
MikeNeilson
left a comment
There was a problem hiding this comment.
Looks good. However, there is one challenge you need to do.
An integration test that actually renders a stacktrace. NOTE: you may need to be a bit contrived here, except that reality.
8ffc4cb to
4c35f30
Compare
| cwms_sec.add_user_to_group('l2hectest_vt','CWMS PD Users', 'HQ'); | ||
| cwms_sec.add_user_to_group('l2hectest_vt','CWMS User Admins', 'HQ'); | ||
| cwms_sec.add_user_to_group('l2hectest_vt','CWMS DBA Users', 'HQ'); | ||
| cwms_sec.add_user_to_group('l2hectest_vt','SHOW STACK TRACE', 'HQ'); |
There was a problem hiding this comment.
Removed these so the tests would pass
MikeNeilson
left a comment
There was a problem hiding this comment.
Generally looks good. A few nitpicks about some of the tests.
| import org.togglz.core.manager.FeatureManager; | ||
|
|
||
| @Tag("integration") | ||
| class ExceptionTraceRenderingTestIT { |
There was a problem hiding this comment.
This test should be of the actual API returning the stack trace appropriate.
There should be no need to Proxy HTTP response or Request. This should be derived from DataApiTestIT so that it runs after the CDA instance is setup.
However, I will grant that it may be a bit difficult to force something to actually output a stack trace. You should be able insert a new handler, within the test code, that does that.
| static FluentLogger logger = FluentLogger.forEnclosingClass(); | ||
| public static final String JSON_FILE = "/cwms/cda/api/lrl/1hour.json"; | ||
|
|
||
| static class StackTraceFeatureExtension implements BeforeEachCallback, AfterEachCallback { |
There was a problem hiding this comment.
Move this to it's own class under fixtures.


Add conditional stack traces for local and development debugging and keeps the existing
incidentIdentifierbehavior used for log discovery.Stack traces are now included in
CdaError.details.stackTracewhen the request isexplicitly configured for trace output:
OR
CWMS User AdminsAND indevenvironment (env.lower().includes('dev'))The implementation keeps
CdaErroras a response DTO and places the request-aware policyin
ErrorTraceSupport.To make that behavior apply consistently, this PR also removes several redundant
controller-level
catch (Exception)wrappers that were bypassingApiServlet, andupdates remaining endpoint
500handlers to make their responses throughErrorTraceSupport.Partly fixes some of
but not the ConnectionPreparingDataSource
Other potentially related issues include:
Trying to centralize general errors where possible and reduce fragmentation
Not trying to solve a new base exception direction, or a better inheritance model mainly because @MikeNeilson said to discuss more before doing that in another issue.