Skip to content

fix [share-modal]: preserve visibility-change error text - #1907

Closed
AbhiramDhanvi wants to merge 2 commits into
layer5io:masterfrom
AbhiramDhanvi:bug/AbhiramDhanvi/1789
Closed

AbhiramDhanvi wants to merge 2 commits into
layer5io:masterfrom
AbhiramDhanvi:bug/AbhiramDhanvi/1789

Conversation

@AbhiramDhanvi

@AbhiramDhanvi AbhiramDhanvi commented Nov 29, 2026 •

Copy link
Copy Markdown

Notes for Reviewers

This PR fixes #1789

What was wrong

When changing visibility failed in ShareModal, users only saw "Failed to update visibility." and never the reason.

The host returns { error: "reason" }, but notifyVisibilityChange read res?.error?.error. Since res.error is already a string, that was always undefined.

What I changed

  • notifyVisibilityChange now reads res?.error directly (it still works if the error comes as an object)
  • Changed !res.error to !res?.error so an undefined response doesn't crash
  • Replaced the any types with proper ones

Test added

In ShareModalWireContract.test.tsx: when handleUpdateVisibility returns { error: 'visibility rejected' }, the notification now shows "Failed to update visibility. visibility rejected".

Lint, build and all tests pass locally.

Signed commits

  • Yes, I signed my commits.

Summary by CodeRabbit

  • Bug Fixes
    • Visibility update failures now display an error notification, including the reason when provided. Notifications handle both plain-text and structured error details, use a general message when no details are available, and report a failure if no response is received. This makes failure messages clearer across different response formats.

Copilot AI balanced review requested due to automatic review settings November 29, 2026 16:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@leecalcote
leecalcote requested a review from miacycle November 29, 2026 16:52
@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

ShareModal now handles visibility-update failures with string or nested error details and uses a generic message when details are absent. Parameterized tests check failure notifications for string, nested-object, and empty error details.

Changes: Visibility update error handling

Layer / File(s) Summary
Normalize and test visibility errors
src/custom/ShareModal/ShareModal.tsx, src/__testing__/ShareModalWireContract.test.tsx
The notification handler accepts an optional typed response, extracts string or nested error details, and uses a generic message when details are absent. Tests check notification messages and the error event type.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related PRs

  • layer5io/sistent#1807: Addresses the same visibility-error message behavior and adds related component tests.

Suggested reviewers: aabidsofi19

Merge Risk: Minimal · up to 36e19

This change makes the visibility-update failure notification include the host's error text. The change is small and tested, and no merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: ShareModal's visibility-change failure notification now keeps the host's error text instead of dropping it. It matches the raw summary, which describes reading the str…
Linked Issues check Passed [#1789] The issue requires the host reason to appear in the visibility-change failure notification when handleUpdateVisibility resolves to { error: string }. At head 36e195a, notifyVisibilityChange in…
Out of Scope Changes check Passed The whole-PR diff against the merge base changes two files. src/custom/ShareModal/ShareModal.tsx changes only notifyVisibilityChange: parameter types (replacing any and removing the no-explicit-any es…
Full details: Title check

Explanation

The title names the main change: ShareModal's visibility-change failure notification now keeps the host's error text instead of dropping it. It matches the raw summary, which describes reading the string error directly and preserving nested-object errors. The title's 'fix [share-modal]:' prefix is a bracketed scope tag, which is a minor style point and does not make the title unrelated.

Full details: Linked Issues check

Explanation

[#1789] The issue requires the host reason to appear in the visibility-change failure notification when handleUpdateVisibility resolves to { error: string }. At head 36e195a, notifyVisibilityChange in src/custom/ShareModal/ShareModal.tsx computes errorDetail as res?.error when it is a string. It falls back to res?.error?.error only for the object form. The message is built as Failed to update visibility. ${errorDetail} when errorDetail is non-empty. The double .error lookup on a string, which caused the defect, is removed. The success check uses !res?.error, so an undefined response no longer throws. The new it.each cases in src/testing/ShareModalWireContract.test.tsx cover { error: 'visibility rejected' } (the issue's acceptance example), a nested object error, and an empty object error. They assert the expected message and event_type 'error'. The revoke path is not changed, which matches the issue's statement that it is already correct. The change since the previous review (the parameterized tests and the bare-message fallback for empty detail) is consistent with the issue. No unmet coding requirement was found.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff against the merge base changes two files. src/custom/ShareModal/ShareModal.tsx changes only notifyVisibilityChange: parameter types (replacing any and removing the no-explicit-any eslint-disable), error-detail extraction, the empty-detail fallback message, and the !res?.error guard. These changes implement the fix for #1789 and the typing cleanup stated in the PR description. src/testing/ShareModalWireContract.test.tsx adds parameterized tests for the same notification path. The tests support the fix and do not cover unrelated behavior. No unrelated change was found.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • 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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 33b3f560-d271-47d7-86ab-282625e52203
Commits

Reviewing files that changed from the base of the PR and between 88ce058 and 36e195a.

Files selected for processing: 2

  • src/__testing__/ShareModalWireContract.test.tsx
  • src/custom/ShareModal/ShareModal.tsx

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@sarajkrishnasingh sarajkrishnasingh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice catch on #1789, this is a focused fix for a genuinely confusing failure mode: users now see the reason a visibility change failed instead of a bare failure message. The string-or-object handling in notifyVisibilityChange matches the host contract (handleUpdateVisibility returns { error: string }), and the new test pins the exact notification text for the string-error case. Dropping the any types and the eslint-disable is a nice cleanup too. Checks are green (DCO, triage, CodeRabbit), and the test coverage fits the change.

One small polish: when the error detail ends up empty, the failure message reads "Failed to update visibility. " with a trailing space. I left a one-click suggestion that only appends the detail when there is one. The object-shaped fallback path has no test of its own yet, so if that shape is still reachable, a second case mirroring the new one would pin it down.

Comment thread src/custom/ShareModal/ShareModal.tsx Resolved
@AbhiramDhanvi AbhiramDhanvi changed the title fix(share-modal): preserve visibility-change error text fix [share-modal]: preserve visibility-change error text Nov 29, 2026
@leecalcote
leecalcote removed the request for review from miacycle November 29, 2026 16:57
@pontusringblom

Copy link
Copy Markdown
Contributor

Good work! You might like to present your work in the upcoming, weekly Meshery development meeting (meshery.io/calendar). If so, I encourage you to add this item in the meeting agenda (meet.meshery.io/dev-minutes), attend, present, and receive feedback.

@MAYANKSHARMA01010

Copy link
Copy Markdown

@AbhiramDhanvi Hey, I noticed your PR also addresses #1789, which is assigned to me. I already have PR #1807 open with the fix and regression tests, awaiting maintainer review. Could we coordinate to avoid duplicating work? Happy to compare our approaches

@AbhiramDhanvi

Copy link
Copy Markdown
Author

@MAYANKSHARMA01010 sure , I will close this pull request as you raised pr first and already got approval from reviewers.

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.

ShareModal discards the host's visibility-change error text (double .error hop on a string)

5 participants