fix(CatalogDetail): skip user profile lookup when card has no owner id#1436
fix(CatalogDetail): skip user profile lookup when card has no owner id#1436pontusringblom merged 1 commit intomasterfrom
Conversation
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>
There was a problem hiding this comment.
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
skipguard touseGetUserProfileByIdQuerywhendetails.userIdis 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.
There was a problem hiding this comment.
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.
| // 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. |
There was a problem hiding this comment.
Collapsed to a single inline line — the why is preserved, the prose is gone.
Summary
RightPanelfireduseGetUserProfileByIdQueryunconditionally, so cards rendered without auserIdhit the server with an empty/invalid UUID.SyntaxError: Unexpected token … is not valid JSON).skip: !details.userIdguard — matches the pattern every othercustom/call site uses when the id comes from props.Root cause
Discovered while tracing the Meshery "Open Recents" console-error loop. Companion PRs:
/api/identity/users/profile/:id.Test plan
tsc --noEmitshows no new errors onRightPanel.tsx(pre-existing unrelated errors elsewhere in the repo).jestpre-commit suite (21 tests) passes./api/identity/users/profile/and noSyntaxErrorin the console.