Skip to content

fix(CatalogDetail): skip user profile lookup when card has no owner id#1436

Merged
pontusringblom merged 1 commit intomasterfrom
fix/right-panel-user-profile-skip
Apr 24, 2026
Merged

fix(CatalogDetail): skip user profile lookup when card has no owner id#1436
pontusringblom merged 1 commit intomasterfrom
fix/right-panel-user-profile-skip

Conversation

@miacycle
Copy link
Copy Markdown
Contributor

Summary

  • RightPanel fired useGetUserProfileByIdQuery unconditionally, so cards rendered without a userId hit the server with an empty/invalid UUID.
  • Upstream returned a plain-text 400/404, which the UI's RTK Query JSON parser then crashed on (SyntaxError: Unexpected token … is not valid JSON).
  • Add a skip: !details.userId guard — matches the pattern every other custom/ call site uses when the id comes from props.

Root cause

Discovered while tracing the Meshery "Open Recents" console-error loop. Companion PRs:

Test plan

  • tsc --noEmit shows no new errors on RightPanel.tsx (pre-existing unrelated errors elsewhere in the repo).
  • jest pre-commit suite (21 tests) passes.
  • Manual: visit a catalog card with no owner id — confirm no network call to /api/identity/users/profile/ and no SyntaxError in the console.

RightPanel fired useGetUserProfileByIdQuery unconditionally. When the
card had no userId the query still hit the server with an empty/invalid
UUID, producing upstream 400/404 responses whose plain-text bodies
broke the UI's JSON parser ("Unexpected token ... is not valid JSON")
and showed up as noisy errors on cards rendered without an owner.

Skip the query when details.userId is falsy — every other RTK Query
call site in the custom/ tree that takes an id from props uses the
same guard.

Signed-off-by: Mia Grenell <miagrenell@layer5.io>
Signed-off-by: Lee Calcote <lee.calcote@layer5.io>
Copilot AI review requested due to automatic review settings April 24, 2026 18:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR prevents CatalogDetail/RightPanel from triggering a user profile fetch when the current catalog card has no userId, avoiding invalid requests and downstream RTK Query JSON parse crashes.

Changes:

  • Add an RTK Query skip guard to useGetUserProfileByIdQuery when details.userId is falsy.
  • Document the rationale inline to explain the avoided failure mode (empty/invalid UUID → plain-text error → JSON parse error).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the RightPanel component to conditionally skip the useGetUserProfileByIdQuery hook when details.userId is missing, preventing unnecessary API calls and potential parsing errors. Feedback suggests that the multi-line comment explaining this logic is too verbose and should be simplified or moved to reduce noise within the component logic.

Comment on lines +64 to +66
// Skip the lookup when the card has no owner id — firing with an empty or
// undefined id reaches the server and surfaces a 400/404 that, upstream,
// leaks a plain-text body which RTK Query cannot parse as JSON.
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.

medium

The multi-line comment explaining the skip logic is verbose and adds unnecessary noise to the component logic. Consider moving this explanation to the PR description or a JSDoc block if documentation is required, or simplifying it to a single line.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Collapsed to a single inline line — the why is preserved, the prose is gone.

@pontusringblom pontusringblom merged commit 4a39df8 into master Apr 24, 2026
9 checks passed
@pontusringblom pontusringblom deleted the fix/right-panel-user-profile-skip branch April 24, 2026 19:06
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.

4 participants