Skip to content

test: remove length invocation testing from SentryInvalidJSONString#8453

Open
NinjaLikesCheez wants to merge 3 commits into
mainfrom
test/invalid-json-string-fix
Open

test: remove length invocation testing from SentryInvalidJSONString#8453
NinjaLikesCheez wants to merge 3 commits into
mainfrom
test/invalid-json-string-fix

Conversation

@NinjaLikesCheez

@NinjaLikesCheez NinjaLikesCheez commented Jul 16, 2026

Copy link
Copy Markdown
Member

📜 Description

💡 Motivation and Context

Why: Apple changes the call stack every now and then and we're playing cat and mouse - couldn't find a use of the invocation checks in a test where it made sense to keep it.

This brings us closer to *OS 27 testing parity (but not there - testFramesOrder() still fails as there's a new async mechanism being used to start XCTest (I think))

💚 How did you test it?

  • Locally ran all tests on 26.4.1 & 27.0

📝 Checklist

You have to check all boxes before merging:

  • [~] I added tests to verify the changes.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

#skip-changelog

Closes #8454


func testSerializationFailsWithFirstValidAndThenInvalidJSONObject() {
let json = [ SentryInvalidJSONString(lengthInvocationsToBeInvalid: 1)]
let json = [ SentryInvalidJSONString()]

@philipphofmann philipphofmann Jul 16, 2026

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.

m: I think this quietly drops coverage of a crash path we care about. Once SentryInvalidJSONString() is invalid from the first length call, this test only hits the isValidJSONObject guard and never reaches the throw-during-serialization branch. That branch is the interesting one: the valid-then-invalid string models data that passes a shallow check and then blows up deep in the encoder — which is exactly the launch crash from #4280 that #4337 added this guard for.

Refs: #4280, #4337

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah, I'm not sure how I missed that - in this case I will revert the changes to this class and add the new *OS 27 stack trace to the filtering logic. Thank you for catching this!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added the new check in c14877b

Why: Apple changes the call stack every now and then and we're playing
cat and mouse - couldn't find a use of the invocation checks in a test
where it made sense to keep it.

This brings us closer to *OS 27 testing parity (but not there -
testFramesOrder still fails)
@NinjaLikesCheez
NinjaLikesCheez force-pushed the test/invalid-json-string-fix branch from d9ab245 to c14877b Compare July 16, 2026 14:58

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c14877b. Configure here.

Comment thread Tests/SentryTests/TestUtils/SentryInvalidJSONString.m Outdated
@[ @"__CFStringEncodeByteStream", @"+[_NSJSONReader validForJSON:depth:allowFragments:]" ];

NSString *callStackSymbol = NSThread.callStackSymbols[1];

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: NSLog statements remain in SentryInvalidJSONString.m despite the commit message indicating they would be removed, causing unnecessary console output during tests.
Severity: MEDIUM

Suggested Fix

Remove the NSLog statements at lines 49 and 54 in Tests/SentryTests/TestUtils/SentryInvalidJSONString.m to align the code with the stated intent of the commit and to clean up test console output.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: Tests/SentryTests/TestUtils/SentryInvalidJSONString.m#L49

Potential issue: The pull request intended to remove debug logging, as stated in the
commit message "test: remove debug logging". However, `NSLog` statements on lines 49 and
54 of `SentryInvalidJSONString.m` were not removed. These statements will execute
repeatedly during test runs that use `SentryInvalidJSONString` for JSON
encoding/decoding, creating excessive console noise and making test output more
difficult to debug.

Also affects:

  • Tests/SentryTests/TestUtils/SentryInvalidJSONString.m:54

Did we get this right? 👍 / 👎 to inform future reviews.

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

Labels

ready-to-merge Use this label to trigger all PR workflows skip-changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: remove length invocation testing from SentryInvalidJSONString

2 participants