Skip to content

Truncate the tail of reason#73

Open
green2k wants to merge 1 commit intoaws-cloudformation:mainfrom
green2k:fix/reason-truncate
Open

Truncate the tail of reason#73
green2k wants to merge 1 commit intoaws-cloudformation:mainfrom
green2k:fix/reason-truncate

Conversation

@green2k
Copy link
Copy Markdown

@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
Copy Markdown

@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)

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
Copy Markdown

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)"

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

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
Copy Markdown

hiroyone commented Feb 5, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants