Skip to content

Truncate the tail of reason #73

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

green2k
Copy link

@green2k green2k commented Mar 13, 2024

It's possible to lose some important information when truncating the beginning of the reason.

This PR updates the implementation in a way, that the tail gets truncated instead.

@sbojarovski
Copy link

@green2k @shakirjames @hyandell @stilvoid @jaymecd

could we please get a review on this PR? it's quite useful for troubleshooting Self-Service catalogs as the most important bit of the error message is usually in the first half of it (rather than the tail)

@@ -224,9 +224,9 @@ def _get_func(self):

def _send(self, status=None, reason="", send_response=_send_response):
if len(str(str(self.Reason))) > 256:
self.Reason = "ERROR: (truncated) " + str(self.Reason)[len(str(self.Reason)) - 240:]
self.Reason = "ERROR: (truncated) " + str(self.Reason)[:240]
Copy link

Choose a reason for hiding this comment

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

Suggested change
self.Reason = "ERROR: (truncated) " + str(self.Reason)[:240]
self.Reason = "ERROR: " + str(self.Reason)[:240] + " (truncated)"

if len(str(reason)) > 256:
reason = "ERROR: (truncated) " + str(reason)[len(str(reason)) - 240:]
reason = "ERROR: (truncated) " + str(reason)[:240]
Copy link

Choose a reason for hiding this comment

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

Suggested change
reason = "ERROR: (truncated) " + str(reason)[:240]
reason = "ERROR: " + str(reason)[:240] + " (truncated)"

@hiroyone
Copy link

hiroyone commented Feb 5, 2025

@shakirjames @hyandell
Could you please take a look at this PR?
My use case also needs better messages.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants