Skip to content

Remove max value length #4988

Description

See

# This is more or less an arbitrary large-ish value for now, so that we allow
# pretty long strings (like LLM prompts), but still have *some* upper limit
# until we verify that removing the trimming completely is safe.
DEFAULT_MAX_VALUE_LENGTH=100_000

which is used in

defstrip_string(value, max_length=None):
# type: (str, Optional[int]) -> Union[AnnotatedValue, str]
ifnotvalue:
returnvalue
ifmax_lengthisNone:
max_length=DEFAULT_MAX_VALUE_LENGTH
byte_size=_get_size_in_bytes(value)
text_size=len(value)
ifbyte_sizeisnotNoneandbyte_size>max_length:
# truncate to max_length bytes, preserving code points
truncated_value=_truncate_by_bytes(value, max_length)
eliftext_sizeisnotNoneandtext_size>max_length:
# fallback to truncating by string length
truncated_value=value[: max_length-3] +"..."
else:
returnvalue
returnAnnotatedValue(
value=truncated_value,
metadata={
"len": byte_sizeortext_size,
"rem": [["!limit", "x", max_length-3, max_length]],
},
)

The strip_string() function is called in

  • sentry_sdk.utils.get_lines_from_file() for obtaining pre- and post context source lines; and
  • sentry_sdk.serializer.serialize(), which is used to serialize events.

Activity

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

Metadata

Metadata

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions