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

BE: Make it possible to hide stacktraces in HTTP responses #536 #537

Closed
wants to merge 1 commit into from

Conversation

mrlittle113
Copy link

  • Breaking change? (if so, please describe the impact and migration path for existing application instances)

What changes did you make? (Give an overview)
Create a flag in application.yml to enable or disable stacktrace include in error responses

Is there anything you'd like reviewers to focus on?
Where to put the config on, this is my first PR so I am not familiar with the project structure!

How Has This Been Tested? (put an "x" (case-sensitive!) next to an item)

  • No need to
  • Manually (please, describe, if necessary)
  • Unit checks
  • Integration checks
  • Covered by existing automation

Checklist (put an "x" (case-sensitive!) next to all the items, otherwise the build will fail)

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (e.g. ENVIRONMENT VARIABLES)
  • My changes generate no new warnings (e.g. Sonar is happy)
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged

Check out Contributing and Code of Conduct

A picture of a cute animal (not mandatory but encouraged)

@mrlittle113 mrlittle113 requested a review from a team as a code owner September 4, 2024 15:16
@kapybro kapybro bot added status/triage Issues pending maintainers triage status/triage/manual Manual triage in progress status/triage/completed Automatic triage completed and removed status/triage Issues pending maintainers triage labels Sep 4, 2024
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi mrlittle113! 👋

Welcome, and thank you for opening your first PR in the repo!

Please wait for triaging by our maintainers.

Please take a look at our contributing guide.

@@ -19,3 +19,7 @@ logging:
reactor.netty.http.server.AccessLog: INFO
org.hibernate.validator: WARN

web:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than setting it to false here, let's define a default state for the property:
@Value("${web.exception.include.stacktrace:false}")

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, look much better!

return ServerResponse
.status(exception.getStatusCode())
.contentType(MediaType.APPLICATION_JSON)
.bodyValue(response);
}

private String getStackTrace(Throwable exception) {
if (!includeStacktraceInException) {
return "";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A dummy value like Redacted for security reasons might be better, what do you think?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, look much better!

@@ -35,6 +36,9 @@
@Order(Ordered.HIGHEST_PRECEDENCE)
public class GlobalErrorWebExceptionHandler extends AbstractErrorWebExceptionHandler {

@Value("${web.exception.include.stacktrace}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add this property into our contracts, so it could be changed in UI via wizard?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you hind me where to put the config on.

I saw that DynamicConfigOperations load config from DYNAMIC_CONFIG_PATH_ENV_PROPERTY which will be overridden on each configuration submission through UI wizard.

And from README I saw that can enable the dynamic through DYNAMIC_CONFIG_ENABLED: 'true' on docker compose.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @Haarolean, could you help me with this.

Can you hind me where to put the config on.

I saw that DynamicConfigOperations load config from DYNAMIC_CONFIG_PATH_ENV_PROPERTY which will be overridden on each configuration submission through UI wizard.

And from README I saw that can enable the dynamic through DYNAMIC_CONFIG_ENABLED: 'true' on docker compose.

Copy link
Member

@Haarolean Haarolean Sep 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can put it temporarily wherever you wish for testing purposes, I like to put mine into /tmp.

which will be overridden on each configuration submission through UI wizard

You have to pass it separately as an arg, like mentioned here: docker run -it -p 8080:8080 -e spring.config.additional-location=/tmp/config.yml -v /tmp/kui/config.yml:/tmp/config.yml ghcr.io/kafbat/kafka-ui (or an equivalent for a jar file).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I will try it out

@Haarolean Haarolean self-requested a review September 11, 2024 20:33
@Haarolean Haarolean linked an issue Sep 27, 2024 that may be closed by this pull request
2 tasks
@Haarolean Haarolean added the hacktoberfest-accepted PRs accepted towards hacktoberfest goal and will be counted as approved label Oct 4, 2024
Copy link

kapybro bot commented Dec 7, 2024

Further user feedback is requested. Please reply within 7 days or we might close the issue.

Copy link

kapybro bot commented Dec 14, 2024

No feedback received within 7 days. Auto closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted PRs accepted towards hacktoberfest goal and will be counted as approved status/triage/completed Automatic triage completed status/triage/manual Manual triage in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BE: Make it possible to hide stacktraces in HTTP responses
2 participants