Fix missing API key value prefix in try-out curl #2715
Conversation
📝 WalkthroughWalkthroughChangesThe PR centralizes API key display resolution, including header name, location, and value prefix. Proxy and service-provider views use the resolved metadata for Swagger defaults and curl snippets, while query credentials are URL-encoded. API key authentication display
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant ProxyOrProviderView
participant AuthDisplayUtility
participant SwaggerViewer
participant ApiTryOutCurlSnippet
ProxyOrProviderView->>AuthDisplayUtility: Resolve API key display metadata
AuthDisplayUtility-->>ProxyOrProviderView: Return header name, location, and value prefix
ProxyOrProviderView->>SwaggerViewer: Supply formatted generated API key
ProxyOrProviderView->>ApiTryOutCurlSnippet: Supply API key and value prefix
ApiTryOutCurlSnippet-->>ProxyOrProviderView: Generate prefixed and encoded curl command
Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
portals/ai-workspace/src/pages/appShell/appShellPages/proxies/LLMProxyOverviewTab.tsx (1)
214-230: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winAdd
apiKeyValuePrefixto Swagger viewer remount key.Both
LLMProxyOverviewTabandServiceProviderOverviewTabuseswaggerViewerKeyto forceSwaggerSpecViewerto remount and pick up new default headers. SinceswaggerDefaultHeadersnow depends onapiKeyValuePrefix, it must be included in the string join and theuseMemodependency array to ensure the viewer reflects prefix changes.
portals/ai-workspace/src/pages/appShell/appShellPages/proxies/LLMProxyOverviewTab.tsx#L214-L230: AddapiKeyValuePrefixto the joined array and the dependency array ofswaggerViewerKey.portals/ai-workspace/src/pages/appShell/appShellPages/serviceProvider/ServiceProviderOverviewTab.tsx#L230-L246: AddapiKeyValuePrefixto the joined array and the dependency array ofswaggerViewerKey.💻 Proposed fix
const swaggerViewerKey = useMemo( () => [ generatedGatewayUrl, apiKeyLocation, apiKeyName, + apiKeyValuePrefix, latestGeneratedKey ?? '', // proxy?.openapi ?? '' OR provider?.openapi ?? '' ].join('::'), [ apiKeyLocation, apiKeyName, + apiKeyValuePrefix, generatedGatewayUrl, latestGeneratedKey, // proxy?.openapi OR provider?.openapi ] );🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@portals/ai-workspace/src/pages/appShell/appShellPages/proxies/LLMProxyOverviewTab.tsx` around lines 214 - 230, Update swaggerViewerKey in LLMProxyOverviewTab.tsx (lines 214-230) and ServiceProviderOverviewTab.tsx (lines 230-246) to include apiKeyValuePrefix in both the joined remount-key values and the useMemo dependency arrays, ensuring SwaggerSpecViewer remounts when the prefix changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In
`@portals/ai-workspace/src/pages/appShell/appShellPages/proxies/LLMProxyOverviewTab.tsx`:
- Around line 214-230: Update swaggerViewerKey in LLMProxyOverviewTab.tsx (lines
214-230) and ServiceProviderOverviewTab.tsx (lines 230-246) to include
apiKeyValuePrefix in both the joined remount-key values and the useMemo
dependency arrays, ensuring SwaggerSpecViewer remounts when the prefix changes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c2725442-159f-4edb-a14d-0fc7b5316694
📒 Files selected for processing (5)
portals/ai-workspace/src/Components/common/ApiTryOutCurlSnippet.tsxportals/ai-workspace/src/pages/appShell/appShellPages/proxies/LLMProxyNew.tsxportals/ai-workspace/src/pages/appShell/appShellPages/proxies/LLMProxyOverviewTab.tsxportals/ai-workspace/src/pages/appShell/appShellPages/serviceProvider/ServiceProviderOverviewTab.tsxportals/ai-workspace/src/utils/apiKeyAuthDisplay.ts
Purpose
The try-out curl in the AI Workspace did not include the configured API key value prefix (e.g.,
Bearer), so copied commands failed gateway API key validation for providers/proxies configured with a prefix.Changes
apiKeyAuthDisplayutility that resolves the effective API key header name, location, and value prefix from the security config and global policies.security.apiKey.keyvalue.UI
When added value prefix from Security tab:


When added as a guardrail:
Resolved : #2714