Skip to content

fix: [AH-2312]: client setup details is giving 500 at account and org level when you select the project level registry scope should be account, org and project#97

Open
abhinavcode wants to merge 4 commits into
mainfrom
AH-2312
Open

fix: [AH-2312]: client setup details is giving 500 at account and org level when you select the project level registry scope should be account, org and project#97
abhinavcode wants to merge 4 commits into
mainfrom
AH-2312

Conversation

@abhinavcode

@abhinavcode abhinavcode commented Feb 25, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features
    • Start repository setup directly from registry pages; the setup modal now preserves and uses registry context.
    • Setup flow will use an encoded registry reference when available to target the correct registry.
    • Added a public export to enable encoding registry paths for components that initiate setup.
    • Introduced a lightweight registry-ref provider and hook so components can access the current registry reference.

… level when you select the project level registry scope should be account, org and project

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@coderabbitai

coderabbitai Bot commented Feb 25, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f5f0141 and 76ef1b0.

📒 Files selected for processing (1)
  • web/src/ar/frameworks/RepositoryStep/RegistryRefContext.tsx

📝 Walkthrough

Walkthrough

Threaded an optional registryRef?: string through widgets, hooks, modal, and consumer components; added a RegistryRef context/provider and exported encodeRef from hooks; computed encoded registry refs in list/tree views and passed them into action widgets; cloned setup client elements to inject registryRef.

Changes

Cohort / File(s) Summary
Widget — inject registryRef
web/src/ar/frameworks/RepositoryStep/RepositorySetupClientWidget.tsx
Add registryRef prop; capture renderSetupClient result, return falsy content directly, or clone valid React element to inject registryRef.
Actions widget & context provider
web/src/ar/frameworks/RepositoryStep/RepositoryActionsWidget.tsx, web/src/ar/frameworks/RepositoryStep/RegistryRefContext.tsx
Add optional registryRef prop on Actions widget; introduce RegistryRefContext, RegistryRefProvider, and useRegistryRef; wrap renderActions output with RegistryRefProvider supplying registryRef.
Modal hook
web/src/ar/pages/repository-details/hooks/useSetupClientModal/useSetupClientModal.tsx
Add optional registryRef to hook props and forward it to RepositorySetupClientWidget.
Setup client consumers
web/src/ar/pages/repository-details/components/Actions/SetupClient.tsx, web/src/ar/pages/repository-details/components/SetupClientContent/SetupClientContent.tsx
Propagate registryRef into modal invocation and into SetupClientContent; SetupClientContent prefers registryRef (prop or computed via useGetSpaceRef) when calling client-setup API.
Types
web/src/ar/pages/repository-details/components/Actions/types.ts
Add optional registryRef?: string to RepositoryActionsProps.
List & Tree producers
web/src/ar/pages/repository-list/components/RepositoryListTable/RepositoryListCells.tsx, web/src/ar/pages/repository-list/components/RepositoryListTreeView/RepositoryListTreeView.tsx
Import encodeRef from hooks, compute registryRef from entity path with encodeRef(...), and pass registryRef into RepositoryActionsWidget for rows/nodes.
Upstream proxy actions
web/src/ar/pages/upstream-proxy-details/components/UpstreamProxyActions/UpstreamProxyActions.tsx
Use useRegistryRef() and forward registryRef to SetupClientMenuItem when rendering table actions.
Hooks barrel
web/src/ar/hooks/index.ts
Export encodeRef from ./useGetSpaceRef in the hooks barrel to expose encoding helper publicly.

Sequence Diagram

sequenceDiagram
    participant UI as SetupClientMenuItem
    participant Modal as useSetupClientModal
    participant Widget as RepositorySetupClientWidget
    participant Content as SetupClientContent
    participant API as ClientSetupAPI

    UI->>Modal: open(registryRef?)
    activate Modal
    Modal->>Widget: render(registryRef?)
    activate Widget
    Widget->>Content: clone element injecting registryRef
    activate Content
    Content->>Content: resolve registryRef (prop || useGetSpaceRef)
    Content->>API: fetch setup details with registry_ref
    activate API
    API-->>Content: setup details
    deactivate API
    Content-->>Widget: rendered content
    deactivate Content
    Widget-->>Modal: rendered widget
    deactivate Widget
    Modal-->>UI: modal ready
    deactivate Modal
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I hop with a tiny hop and grin,
Passing registry refs tucked in,
Encoded paths like carrot trails,
Widgets clone and hooks set sails,
A rabbit cheers: the modal's win! 🐇

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the fix: addressing a 500 error in client setup details when selecting project-level registry scope, with the scope needing to support account, org, and project levels.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch AH-2312

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
web/src/ar/frameworks/RepositoryStep/RepositorySetupClientWidget.tsx (1)

52-61: Add a validity guard before cloneElement.

React.cloneElement will throw if renderSetupClient ever returns null or a non-element value. A lightweight React.isValidElement guard makes this path safer.

Proposed hardening
   const content = repositoryType.renderSetupClient({
     onClose,
     repoKey,
     artifactKey,
     versionKey
   })
-  return React.cloneElement(content as React.ReactElement, {
+  if (!React.isValidElement(content)) {
+    return <Text intent="warning">{getString('stepNotFound')}</Text>
+  }
+  return React.cloneElement(content, {
     isSentFromRegistryPage,
     registryPath
   })
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/ar/frameworks/RepositoryStep/RepositorySetupClientWidget.tsx` around
lines 52 - 61, The code calls React.cloneElement on the value returned by
repositoryType.renderSetupClient without checking it's a valid React element;
add a guard using React.isValidElement(content) before cloning to avoid runtime
throws, and if it's not valid return null or fallback UI. Locate the variable
content (from repositoryType.renderSetupClient) and the clone call
(React.cloneElement(..., { isSentFromRegistryPage, registryPath })) and wrap the
clone in a validity check so only valid React elements are cloned.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@web/src/ar/pages/repository-details/components/Actions/SetupClient.tsx`:
- Around line 33-34: The current object blindly sets isSentFromRegistryPage:
true while registryPath may be undefined; change to compute registryPath first
from (data as { path?: string }).path and set isSentFromRegistryPage to a
boolean based on its presence (e.g., !!registryPath) so registry mode is only
enabled when registryPath exists; update any uses of
registryPath/isSentFromRegistryPage accordingly in SetupClient.tsx.

---

Nitpick comments:
In `@web/src/ar/frameworks/RepositoryStep/RepositorySetupClientWidget.tsx`:
- Around line 52-61: The code calls React.cloneElement on the value returned by
repositoryType.renderSetupClient without checking it's a valid React element;
add a guard using React.isValidElement(content) before cloning to avoid runtime
throws, and if it's not valid return null or fallback UI. Locate the variable
content (from repositoryType.renderSetupClient) and the clone call
(React.cloneElement(..., { isSentFromRegistryPage, registryPath })) and wrap the
clone in a validity check so only valid React elements are cloned.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9680578 and f903968.

📒 Files selected for processing (5)
  • web/src/ar/frameworks/RepositoryStep/RepositorySetupClientWidget.tsx
  • web/src/ar/hooks/index.ts
  • web/src/ar/pages/repository-details/components/Actions/SetupClient.tsx
  • web/src/ar/pages/repository-details/components/SetupClientContent/SetupClientContent.tsx
  • web/src/ar/pages/repository-details/hooks/useSetupClientModal/useSetupClientModal.tsx

Comment thread web/src/ar/pages/repository-details/components/Actions/SetupClient.tsx Outdated
… level when you select the project level registry scope should be account, org and project

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
web/src/ar/frameworks/RepositoryStep/RepositorySetupClientWidget.tsx (1)

61-64: Consider adding guards for intrinsic/Fragment elements and improving prop typing for cloneElement.

While the abstract method signature constrains renderSetupClient to return JSX.Element and all current implementations return the SetupClientContent component (never intrinsic elements or fragments), adding defensive checks would prevent future implementations from accidentally returning unsupported element types. Additionally, the broad type cast on line 64 can be tightened.

Suggested refactor
-  if (!content || !React.isValidElement(content)) {
+  if (
+    !content ||
+    !React.isValidElement(content) ||
+    typeof content.type === 'string' ||
+    content.type === React.Fragment
+  ) {
     return content
   }
-  return React.cloneElement(content, {
+  type RegistryInjectedProps = {
+    isSentFromRegistryPage?: boolean
+    registryPath?: string
+  }
+  return React.cloneElement(content as React.ReactElement<RegistryInjectedProps>, {
     isSentFromRegistryPage,
     registryPath
-  } as React.Attributes & { isSentFromRegistryPage?: boolean; registryPath?: string })
+  })
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/ar/frameworks/RepositoryStep/RepositorySetupClientWidget.tsx` around
lines 61 - 64, The cloneElement call in RepositorySetupClientWidget should
defensively ensure renderSetupClient() returns a valid React element of the
expected component type and tighten the prop typing instead of a broad cast;
update RepositorySetupClientWidget to check that content is a
React.isValidElement and not a Fragment/intrinsic (e.g., typeof content.type ===
'string' or content.type === React.Fragment) and only call React.cloneElement
when content is a component element (matching SetupClientContent or a
ComponentType), otherwise render content as-is or wrap it; replace the loose
cast on the cloneElement props with a stricter generic typed props/interface for
the added props (isSentFromRegistryPage?: boolean; registryPath?: string) so
cloneElement<SetupClientContentProps>(...) enforces types and avoids unsafe
casting.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@web/src/ar/frameworks/RepositoryStep/RepositorySetupClientWidget.tsx`:
- Around line 61-64: The cloneElement call in RepositorySetupClientWidget should
defensively ensure renderSetupClient() returns a valid React element of the
expected component type and tighten the prop typing instead of a broad cast;
update RepositorySetupClientWidget to check that content is a
React.isValidElement and not a Fragment/intrinsic (e.g., typeof content.type ===
'string' or content.type === React.Fragment) and only call React.cloneElement
when content is a component element (matching SetupClientContent or a
ComponentType), otherwise render content as-is or wrap it; replace the loose
cast on the cloneElement props with a stricter generic typed props/interface for
the added props (isSentFromRegistryPage?: boolean; registryPath?: string) so
cloneElement<SetupClientContentProps>(...) enforces types and avoids unsafe
casting.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f903968 and 7637bda.

📒 Files selected for processing (2)
  • web/src/ar/frameworks/RepositoryStep/RepositorySetupClientWidget.tsx
  • web/src/ar/pages/repository-details/components/Actions/SetupClient.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/src/ar/pages/repository-details/components/Actions/SetupClient.tsx

… level when you select the project level registry scope should be account, org and project

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
web/src/ar/pages/repository-details/hooks/useSetupClientModal/useSetupClientModal.tsx (1)

38-67: ⚠️ Potential issue | 🟠 Major

Add dependency array to useModalHook call to ensure modal reflects prop changes.

The useModalHook memoizes the component factory based on an inputs dependency array (second parameter). useSetupClientModal omits this parameter, causing all captured props—repoKey, artifactKey, versionKey, packageType, onClose, and registryRef—to become stale closures. If any prop changes after the hook is called but before the modal is opened, the change is not reflected.

Pass [packageType, repoKey, artifactKey, versionKey, onClose, registryRef] as the second argument to useModalHook, matching the pattern used in useCreateLabelModal and useCreateRepositoryModal.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@web/src/ar/pages/repository-details/hooks/useSetupClientModal/useSetupClientModal.tsx`
around lines 38 - 67, The modal factory passed into useModalHook inside
useSetupClientModal currently omits the inputs dependency array, causing
captured props (repoKey, artifactKey, versionKey, packageType, onClose,
registryRef) to become stale; fix it by passing an inputs array as the second
argument to useModalHook — e.g. useModalHook(() => { ... }, [packageType,
repoKey, artifactKey, versionKey, onClose, registryRef]) — so the
Drawer/RepositorySetupClientWidget sees updated props when opened.
🧹 Nitpick comments (2)
web/src/ar/pages/repository-details/components/SetupClientContent/SetupClientContent.tsx (1)

41-58: artifactKey / versionKey not destructured alongside other props.

Line 42 destructures most props but leaves artifactKey and versionKey on props, accessed as props.artifactKey and props.versionKey on lines 55–56. Minor consistency nit.

♻️ Proposed cleanup
-  const { onClose, packageType, repoKey, registryRef: registryRefProp } = props
+  const { onClose, packageType, repoKey, artifactKey, versionKey, registryRef: registryRefProp } = props
   ...
     queryParams: {
-      artifact: props.artifactKey,
-      version: props.versionKey
+      artifact: artifactKey,
+      version: versionKey
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@web/src/ar/pages/repository-details/components/SetupClientContent/SetupClientContent.tsx`
around lines 41 - 58, Destructure artifactKey and versionKey from props in
SetupClientContent alongside onClose, packageType, repoKey, and registryRefProp
so the call to useGetClientSetupDetailsQuery uses artifactKey and versionKey
directly; update the useGetClientSetupDetailsQuery call (and any other usages)
to reference the local variables artifactKey and versionKey instead of
props.artifactKey / props.versionKey to keep prop access consistent and concise.
web/src/ar/pages/repository-list/components/RepositoryListTreeView/RepositoryListTreeView.tsx (1)

154-167: Redundant optional chain on the type assertion.

(metadata as { path?: string })?.path — the optional chain (?.) after the cast is a no-op because a type assertion never returns null or undefined; metadata itself is already in scope. The path?: string in the cast already communicates that the property may be absent.

♻️ Minor simplification
-        const path = (metadata as { path?: string })?.path
+        const path = (metadata as { path?: string }).path
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@web/src/ar/pages/repository-list/components/RepositoryListTreeView/RepositoryListTreeView.tsx`
around lines 154 - 167, In the TreeNodeEntityEnum.REGISTRY case simplify the
redundant optional chaining on the type assertion: replace the expression
(metadata as { path?: string })?.path with a direct property access on the
asserted type so that registryRef is derived from (metadata as { path?: string
}).path (or pull that asserted type into a small const named path) before
calling encodeRef; update references around
registryRef/encodeRef/RepositoryActionsWidget accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@web/src/ar/pages/upstream-proxy-details/components/UpstreamProxyActions/UpstreamProxyActions.tsx`:
- Line 32: Create a new RegistryRefContext module that exports a React context,
a RegistryRefProvider component, and the useRegistryRef hook; implement
RegistryRefContext to hold the registry reference state (e.g., registryRef value
and a setter), ensure RegistryRefProvider accepts children and provides the
context value, and implement useRegistryRef to read the context and throw a
clear error if used outside the provider; export both RegistryRefProvider and
useRegistryRef so RepositoryActionsWidget.tsx and UpstreamProxyActions.tsx can
import them.

---

Outside diff comments:
In
`@web/src/ar/pages/repository-details/hooks/useSetupClientModal/useSetupClientModal.tsx`:
- Around line 38-67: The modal factory passed into useModalHook inside
useSetupClientModal currently omits the inputs dependency array, causing
captured props (repoKey, artifactKey, versionKey, packageType, onClose,
registryRef) to become stale; fix it by passing an inputs array as the second
argument to useModalHook — e.g. useModalHook(() => { ... }, [packageType,
repoKey, artifactKey, versionKey, onClose, registryRef]) — so the
Drawer/RepositorySetupClientWidget sees updated props when opened.

---

Nitpick comments:
In
`@web/src/ar/pages/repository-details/components/SetupClientContent/SetupClientContent.tsx`:
- Around line 41-58: Destructure artifactKey and versionKey from props in
SetupClientContent alongside onClose, packageType, repoKey, and registryRefProp
so the call to useGetClientSetupDetailsQuery uses artifactKey and versionKey
directly; update the useGetClientSetupDetailsQuery call (and any other usages)
to reference the local variables artifactKey and versionKey instead of
props.artifactKey / props.versionKey to keep prop access consistent and concise.

In
`@web/src/ar/pages/repository-list/components/RepositoryListTreeView/RepositoryListTreeView.tsx`:
- Around line 154-167: In the TreeNodeEntityEnum.REGISTRY case simplify the
redundant optional chaining on the type assertion: replace the expression
(metadata as { path?: string })?.path with a direct property access on the
asserted type so that registryRef is derived from (metadata as { path?: string
}).path (or pull that asserted type into a small const named path) before
calling encodeRef; update references around
registryRef/encodeRef/RepositoryActionsWidget accordingly.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7637bda and f5f0141.

📒 Files selected for processing (10)
  • web/src/ar/frameworks/RepositoryStep/RepositoryActionsWidget.tsx
  • web/src/ar/frameworks/RepositoryStep/RepositorySetupClientWidget.tsx
  • web/src/ar/pages/repository-details/components/Actions/RepositoryActions.tsx
  • web/src/ar/pages/repository-details/components/Actions/SetupClient.tsx
  • web/src/ar/pages/repository-details/components/Actions/types.ts
  • web/src/ar/pages/repository-details/components/SetupClientContent/SetupClientContent.tsx
  • web/src/ar/pages/repository-details/hooks/useSetupClientModal/useSetupClientModal.tsx
  • web/src/ar/pages/repository-list/components/RepositoryListTable/RepositoryListCells.tsx
  • web/src/ar/pages/repository-list/components/RepositoryListTreeView/RepositoryListTreeView.tsx
  • web/src/ar/pages/upstream-proxy-details/components/UpstreamProxyActions/UpstreamProxyActions.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/src/ar/frameworks/RepositoryStep/RepositorySetupClientWidget.tsx

… level when you select the project level registry scope should be account, org and project
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