Skip to content

Considerably raise DEFAULT_MAX_VALUE_LENGTH - #4632

Merged
sentrivana merged 12 commits into
masterfrom
ivana/bump-max-value-length-limit
Jul 29, 2025
Merged

Considerably raise DEFAULT_MAX_VALUE_LENGTH#4632
sentrivana merged 12 commits into
masterfrom
ivana/bump-max-value-length-limit

Conversation

@sentrivana

@sentrivanasentrivana commented Jul 28, 2025

Copy link
Copy Markdown
Contributor

AI prompts/messages are potentially huge.

  • raise DEFAULT_MAX_VALUE_LENGTH (responsible for string trimming) from 1024 to 100 000
  • adapt tests (and make them more generic, without hardcoded parts, where possible)

This does not seem to affect issue grouping, see e.g. https://sentry-sdks.sentry.io/issues/6774464781/events/latest/?project=4506716433416192&query=is%3Aunresolved&referrer=latest-event

@codecov

codecovBot commented Jul 28, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.74%. Comparing base (fd7dca4) to head (3ca41a0).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@ Coverage Diff @@## master #4632 +/- ##
=======================================
Coverage 80.74% 80.74% =======================================
Files 156 156 Lines 16630 16630 Branches 2830 2830 =======================================
Hits 13428 13428 Misses 2312 2312 Partials 890 890 
Files with missing linesCoverage Δ
sentry_sdk/consts.py94.73% <100.00%> (ø)

@sentrivana
sentrivana marked this pull request as ready for review July 29, 2025 07:39
@sentrivana
sentrivana requested a review from a team as a code ownerJuly 29, 2025 07:39
Comment threadsentry_sdk/consts.py

# up top to prevent circular import due to integration import
DEFAULT_MAX_VALUE_LENGTH = 1024
DEFAULT_MAX_VALUE_LENGTH = 100_000

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not use sys.maxsize here? Then, we definitely should never need to bump this limit again.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In any case, let's add a code comment to document how we picked the value we end up going with

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Talked about this offline -- and added a comment

@sentrivana
sentrivana enabled auto-merge (squash) July 29, 2025 11:34
Comment threadtests/test_client.py
(event,) = events

assert len(json.dumps(event)) < 10000
assert len(json.dumps(event)) < DEFAULT_MAX_VALUE_LENGTH * 10

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: String Truncation Test Assertion Too Weak

The assertion in test_databag_string_stripping is too weak, defeating the test's purpose. This test is designed to verify that large strings are truncated to keep serialized event sizes manageable. However, the current assertion len(json.dumps(event)) < DEFAULT_MAX_VALUE_LENGTH * 10 allows the serialized event to be as large as the input string (1,000,000 bytes, given DEFAULT_MAX_VALUE_LENGTH = 100_000). This fails to ensure that truncation is actually occurring and keeping the event size manageable. The assertion should be tightened to effectively test string stripping, similar to the original < 10000 bound.

Locations (1)
Fix in CursorFix in Web

@sentrivana
sentrivana merged commit 4f9d326 into masterJul 29, 2025
138 checks passed
@sentrivana
sentrivana deleted the ivana/bump-max-value-length-limit branch July 29, 2025 11:41
alexander-alderman-webb added a commit that referenced this pull request Nov 28, 2025
Remove the default string limit applied when serializing envelopes.
The `max_value_length` parameter now accepts `None`, which disables string truncation. The default value is changed to `None`.
The change follows on from raising the limit in #4632.
Replaces `DEFAULT_MAX_VALUE_LENGTH` with the value 1024 in tests, which was the original limit.
Closes#4988
Sign up for freeto 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.

2 participants

@sentrivana@szokeasaurusrex