Skip to content

Fix null export (#69) and stale export after clear-retrace (#106)#108

Open
kellenmurphy wants to merge 1 commit into
simplesamlphp:mainfrom
kellenmurphy:fix/null-export
Open

Fix null export (#69) and stale export after clear-retrace (#106)#108
kellenmurphy wants to merge 1 commit into
simplesamlphp:mainfrom
kellenmurphy:fix/null-export

Conversation

@kellenmurphy
Copy link
Copy Markdown
Contributor

This fixes two bugs that both cause the export to silently fail.

The first (related to #69) happens when a request is blocked, cancelled, or interrupted before a response arrives. getResponse() returns undefined, which gets passed to createFromJSON. Inside there, JSON.stringify(undefined) doesn't produce a string — it returns the JS value undefined — so JSON.parse throws a SyntaxError. The exception goes uncaught, ui.exportResult is never updated, and the downloaded file contains just null. The fix is a one-line null guard in enrichWithResponse in SAMLTraceIO.js.

The second (related to #106) happens when a request entry has isVisible set but parsed was never populated — this can occur when onHeadersReceived fires before onBeforeSendHeaders in a clear-and-retrace scenario. The export filter maps req.parsed across all entries, producing undefined in the array, which crashes createFromJSON and leaves ui.exportResult stale. The fix is .filter(Boolean) after the .map call in exportDialog.js.

Both fixes are covered by Jest unit tests and Playwright end-to-end tests. The Playwright suite lives on the playwright-testing branch at https://github.com/kellenmurphy/SAML-tracer/tree/playwright-testing — see E2E_TESTS.md there for context and instructions on running the tests. Each bug test was confirmed to fail on unfixed code and pass with the fix applied.

Adds Jest test suite and CI workflow. Guards enrichWithResponse against
null/undefined from getResponse() (simplesamlphp#69), and filters undefined parsed
entries from the export request list (simplesamlphp#106).
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.

1 participant