You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(frontend): show audit log rule changes as JSON instead of [object Object] - #8893
I have added information to docs/ if required so people know about the feature.
I have filled in the "Changes" section below.
I have filled in the "How did you test this code" section below.
Changes
The audit log item page passes each change_details entry to DiffString. For a segment rules update the values are arrays of objects (rules_data), and DiffString rendered them as text, so the page showed [object Object].
This adds stringifyDiffValue (common/utils/diffValue.ts). Primitives and empty values behave as before. Objects and arrays are pretty-printed with JSON.stringify(value, null, 2). DiffString uses the helper for rendering, for the line-number check and for the "unchanged" comparison: two equal arrays are different references, so === never matched. The AuditLogDetail and DiffString value types are widened to allow objects.
How did you test this code?
New unit test common/utils/__tests__/diffValue.test.ts covers null/undefined, the empty string, primitives, and an array of segment rules. That last case checks the output has no [object Object] and parses back to the original rules. npx jest common/utils/__tests__/diffValue.test.ts passes, and Prettier passes on the touched files.
This change was prepared with the assistance of an AI coding agent (Claude).
… Object]
DiffString interpolated values with a template literal, so object and array
values such as a segment's rules_data rendered as "[object Object]" on the
audit log item page. Pretty-print objects as JSON (shared helper) and compare
by the rendered string.
FixesFlagsmith#8867 (display part only)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Audit log change-detail values now accept objects. The new stringifyDiffValue function formats nullish values, empty strings, objects, and other values. DiffString uses the formatted values for equality checks, highlighting, diff viewer input, and multiline detection. Tests cover the formatter’s output for nullish values, empty strings, primitives, and arrays of objects.
Serialize object values in the E2E rendering branch before merging: the current change breaks typechecking and can crash audit details during end-to-end testing. Reusing formatted values would also reduce unnecessary work for large audit entries.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
23-25: Trivial · Maintainability & Code Quality · Low value
Assert the pretty-printed JSON output.
If the formatter loses its indentation argument, this test still passes. If neither diff value contains a newline, the audit diff also hides line numbers.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: ASSERTIVE
Plan: Advanced
Run ID: 280808cc-79cb-4526-be9c-049fe4a7ae20
Commits
Reviewing files that changed from the base of the PR and between eeac04b and ebbc64c.
Files selected for processing: 4
frontend/common/types/responses.ts
frontend/common/utils/__tests__/diffValue.test.ts
frontend/common/utils/diffValue.ts
frontend/web/components/diff/DiffString.tsx
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
curl -fsSL --max-time 20 https://unpkg.com/@types/react@19.3.0/index.d.ts | awk '/type ReactNode =/{show=1; count=0} show {print NR ":" $0; count++; if(count==18)show=0} /interface DOMAttributes<T>/{show2=1; count2=0} show2 {print NR ":" $0; count2++; if(count2==12)show2=0} /div: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>/{print NR ":" $0}'
nl -ba frontend/e2e/helpers/e2e-helpers.playwright.ts | sed -n '795,835p'
Repository: Flagsmith/flagsmith
Length of output: 3365
Serialise objects in the E2E branch.
When rules_data contains rule objects, React cannot render the audit-log detail in E2E mode. The widened types also cause typechecking to fail. Serialise objects in this branch while preserving primitive values.
If an audit detail changes from 1 to "1", this comparison renders an unchanged row. Compare and display values in a way that preserves their types, while retaining JSON rendering for objects and arrays.
For large rules_data values, repeated serialisation can delay the audit detail view. Reuse each rendered value for the comparison, diff props and newline check.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
front-endIssue related to the React Front End Dashboard
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contributes to #8867 (the display part; the duplicate "Segment created" entry is backend behaviour and is left for a separate change).
docs/if required so people know about the feature.Changes
The audit log item page passes each
change_detailsentry toDiffString. For a segment rules update the values are arrays of objects (rules_data), andDiffStringrendered them as text, so the page showed[object Object].This adds
stringifyDiffValue(common/utils/diffValue.ts). Primitives and empty values behave as before. Objects and arrays are pretty-printed withJSON.stringify(value, null, 2).DiffStringuses the helper for rendering, for the line-number check and for the "unchanged" comparison: two equal arrays are different references, so===never matched. TheAuditLogDetailandDiffStringvalue types are widened to allow objects.How did you test this code?
New unit test
common/utils/__tests__/diffValue.test.tscovers null/undefined, the empty string, primitives, and an array of segment rules. That last case checks the output has no[object Object]and parses back to the original rules.npx jest common/utils/__tests__/diffValue.test.tspasses, and Prettier passes on the touched files.This change was prepared with the assistance of an AI coding agent (Claude).