UN-2946 [MISC] Restore Prompt Studio public sharing after lookups V2 wiring#1963
Conversation
…iring Three issues broke /promptStudio/share/* after the lookups V2 PR: - The global useAxiosPrivate response interceptor calls logout() on any 401. An authenticated probe leaking into the anonymous share viewer (e.g. the new useLookupDirtySeed hook on first mount) returned 401 and redirected the share page through /api/v1/logout. Skip the logout when the current path is /promptStudio/share/* — the viewer has no session to expire. - The local Traefik router only forwarded /api/v1 and /deployment to the backend; /public/share/* fell through to the Vite dev server and the share endpoints returned the SPA index instead of JSON. Add /public to the backend rule (and to the frontend negative match) in both the compose labels and the sample proxy override. - The Combined Output JSON view defaulted to the Raw tab even when an enriched lookup output existed. For anonymous share viewers the enriched value is the point of the project; default activeView to Enriched when isPublicSource. The existing useEffect already falls back to Raw when no enriched data is present, so projects without lookups are unaffected. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
Summary by CodeRabbit
WalkthroughTraefik routing was updated to account for /public paths; the frontend 401 handler suppresses logout for public-share viewer routes; JsonView defaults to the Enriched view for public sources and falls back to Raw when enriched output is absent. Public Content Sharing Infrastructure
sequenceDiagram
participant Client as Client (browser)
participant Traefik as Traefik proxy
participant Frontend as Frontend app
participant Backend as Backend API
participant Auth as Auth/logout flow
Client->>Traefik: HTTP request (e.g., /public or frontend paths)
Traefik-->>Backend: Route to Backend when PathPrefix('/public') matches
Traefik-->>Frontend: Route frontend requests (compose excludes /public)
Client->>Frontend: Load public share page (/promptStudio/share/...)
Frontend->>Backend: API request
Backend-->>Frontend: 401 response
Frontend->>Auth: 401 handler checks globalThis.location.pathname
alt path starts with /promptStudio/share/
Auth-->>Frontend: skip logout, log warning, return rejected error
else
Auth-->>Frontend: trigger logout flow
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
|
| Filename | Overview |
|---|---|
| frontend/src/hooks/useAxiosPrivate.js | Added path-based guard to suppress 401→logout on /promptStudio/share/ routes, with a console.warn breadcrumb; logic is correct and low-risk |
| frontend/src/components/custom-tools/combined-output/JsonView.jsx | Reads isPublicSource from store to default tab to "Enriched" for public viewers; didInitTab ref prevents re-render from stomping manual Raw toggle; hydration race addressed via useEffect deps on both enrichedOutput and isPublicSource |
| docker/docker-compose.yaml | Adds PathPrefix(/public) to backend Traefik rule and corresponding !PathPrefix(/public) to frontend negative-match; mirrors existing pattern for /api/v1 and /deployment |
| docker/sample.proxy_overrides.yaml | Adds /public to backend router rule; frontend catch-all relies correctly on Traefik specificity (backend rule always wins for more-specific paths) |
Sequence Diagram
sequenceDiagram
participant Browser as Anonymous Browser
participant Frontend as Frontend (React)
participant Traefik as Traefik Proxy
participant Backend as Backend (Django)
Browser->>Traefik: "GET /promptStudio/share/<id>"
Traefik->>Frontend: (SPA catch-all)
Frontend-->>Browser: Render PublicPromptStudioHelper
Note over Frontend: isPublicSource = true
Note over Frontend: JsonView defaults to Enriched
Frontend->>Traefik: GET /public/share/prompt-studio-metadata/
Traefik->>Backend: (PathPrefix /public → backend)
Backend-->>Frontend: 200 JSON metadata
Frontend->>Traefik: GET /api/v1/undefined/.../check_deployment_usage/
Note over Frontend: useLookupDirtySeed probe — orgId undefined
Traefik->>Backend: forwards
Backend-->>Frontend: 401
Note over Frontend: useAxiosPrivate interceptor
Note over Frontend: pathname starts with /promptStudio/share/
Note over Frontend: console.warn, skip logout()
Frontend-->>Browser: Page remains visible, outputs shown
Reviews (6): Last reviewed commit: "UN-2946 [FIX] Address review on public-s..." | Re-trigger Greptile
Drop incident/context references; keep one-line WHYs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- useAxiosPrivate: trailing slash so the prefix doesn't match unintended siblings of /promptStudio/share/. - JsonView: re-sync activeView when isPublicSource or enrichedOutput changes, not just on first mount, to survive store hydration order. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Resolves SonarCloud S7764 findings on useAxiosPrivate.js. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
athul-rs
left a comment
There was a problem hiding this comment.
Two findings I'd like resolved (or at least called out as intended) before merge. Everything else is a suggestion and can go in a follow-up.
- Log a console.warn breadcrumb when a 401 is suppressed on the public share route so stray authenticated probes don't go silent. - Gate the JsonView Enriched default behind a first-load ref so the default fires once and a manual Raw toggle isn't stomped on re-renders. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Frontend Lint Report (Biome)✅ All checks passed! No linting or formatting issues found. |
|



What
/promptStudio/share/<id>), which started breaking after the lookups V2 PR (UN-2946 [FEAT] Prompt Studio lookups bridge, executor hook, and IDE wiring (OSS side) #1929) shipped./public/share/*to the backend through the local Traefik proxy.Why
useLookupDirtySeed(cloud plugin) which mounts unconditionally insideToolIdeand probes/api/v1/unstract/<orgId>/prompt-studio/<toolId>/check_deployment_usage/. In the anonymous share viewerorgIdisundefinedand the request 401s. The globaluseAxiosPrivateresponse interceptor callslogout()on any 401, redirecting the share page through/api/v1/logout. The share viewer has no session to expire, so the interceptor was effectively bricking the page./api/v1and/deploymentto the backend, so/public/share/*fell through to the Vite dev server and returned the SPA index HTML instead of JSON. Staging works only because the staging ingress already has a/publicrule.How
frontend/src/hooks/useAxiosPrivate.js: gatelogout()behind!window.location.pathname.startsWith("/promptStudio/share"). A 401 on the share viewer is a misrouted authenticated probe, not an expired session.docker/docker-compose.yamlanddocker/sample.proxy_overrides.yaml: addPathPrefix(/public)to the backend Traefik rule and exclude/publicfrom the frontend negative-match.frontend/src/components/custom-tools/combined-output/JsonView.jsx: readisPublicSourcefrom the custom-tool store and initializeactiveViewto"Enriched"when true. The existinguseEffectalready falls back to "Raw" when no enriched data is present, so non-lookup projects are unaffected.Can this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)
/promptStudio/share. Authenticated editor flows still calllogout()on session expiry as before.docker-compose.yaml+sample.proxy_overrides.yaml); the staging/prod ingresses are unchanged and already route/publiccorrectly.JsonViewdefault-tab change is gated onisPublicSource. Editor sessions still default to "Raw".Database Migrations
Env Config
Relevant Docs
Related Issues or PRs
Dependencies Versions
Notes on Testing
python copy_cloud_deps.py -yfrom the cloud worktree into the OSS worktree.VERSION=public-share-test docker compose -f docker-compose.yaml -f compose.override.yaml build frontend backendandup -d frontend backend./api/v1/logoutredirect./api/v1/unstract/undefined/prompt-studio/.../check_deployment_usage/call./public/share/prompt-studio-metadata/,/document-metadata/,/profiles-metadata/,/outputs-metadata/all return 200 JSON viafrontend.unstract.localhost.Screenshots
N/A — behavioural fix; no UI redesign.
Checklist
I have read and understood the Contribution Guidelines.