Skip to content

🌱 Migrate card fetch() calls to useCache/useCached* hooks#13319

Merged
kubestellar-hive[bot] merged 2 commits into
mainfrom
fix/13311
May 12, 2026
Merged

🌱 Migrate card fetch() calls to useCache/useCached* hooks#13319
kubestellar-hive[bot] merged 2 commits into
mainfrom
fix/13311

Conversation

@kubestellar-hive
Copy link
Copy Markdown
Contributor

Fixes #13311

Migrates quantum card components from direct GET fetch() calls to the useCache/useCached* hook system for consistent caching, demo fallback, and loading state management.

Changes

  • web/src/hooks/useCachedQuantum.ts
  • web/src/hooks/useCachedData.ts
  • web/src/components/cards/quantum/QuantumCircuitViewer.tsx
  • web/src/components/cards/quantum/QuantumStatus.tsx
  • web/src/components/cards/quantum/QuantumQubitGrid.tsx
  • web/src/components/cards/quantum/QuantumControlPanel.tsx
  • Created shared cached quantum hooks for status, auth status, circuit ASCII, and qubit grid data
  • Wired isDemoData and isRefreshing into useCardLoadingState/useReportCardDataState
  • Replaced the 8 straightforward GET calls in the quantum cards; RSSFeed and NightlyE2EStatus remain for follow-up, while CubeFS/Harbor already use cached wrappers in main
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Copilot <copilot@github.com>
Copilot AI review requested due to automatic review settings May 12, 2026 17:00
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label May 12, 2026
@kubestellar-prow
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign eeshaansa for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@netlify
Copy link
Copy Markdown

netlify Bot commented May 12, 2026

Deploy Preview for kubestellarconsole ready!

Name Link
🔨 Latest commit 4becb73
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/6a0362feb8b7900008f16f45
😎 Deploy Preview https://deploy-preview-13319.console-deploy-preview.kubestellar.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@kubestellar-prow kubestellar-prow Bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label May 12, 2026
@github-actions github-actions Bot added the ai-generated Pull request generated by AI label May 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

👋 Hey @kubestellar-hive[bot] — thanks for opening this PR!

🤖 This project is developed exclusively using AI coding assistants.

Please do not attempt to code anything for this project manually.
All contributions should be authored using an AI coding tool such as:

This ensures consistency in code style, architecture patterns, test coverage,
and commit quality across the entire codebase.


This is an automated message.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Copilot <copilot@github.com>
@kubestellar-hive kubestellar-hive Bot merged commit 574cdb0 into main May 12, 2026
31 of 32 checks passed
@kubestellar-prow kubestellar-prow Bot deleted the fix/13311 branch May 12, 2026 17:45
@github-actions
Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

Check out what's new:

Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey

Copy link
Copy Markdown
Contributor Author

@kubestellar-hive kubestellar-hive Bot left a comment

Choose a reason for hiding this comment

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

Security Review — sec-check agent

P2: Raw server error body exposed to users

In useCachedQuantum.ts, the fetchQuantumJson helper throws the raw HTTP response body as an error:

const body = await response.text().catch(() => "")
throw new Error(body.trim() || `Failed to fetch quantum data (${response.status})`)

This error string surfaces in UI components (e.g. QuantumCircuitViewer.tsx:85). Server error bodies may contain stack traces, internal paths, or database details.

Fix: Drop the raw body; use a generic message:

throw new Error(`Failed to fetch quantum data (${response.status})`)

Positives

  • Removes 11 console.log/console.error statements (net improvement)
  • All fetch calls have AbortSignal.timeout(FETCH_DEFAULT_TIMEOUT_MS)
  • No credentials cached — only status data
  • No new innerHTML/dangerouslySetInnerHTML
  • Hook ordering correct (data hooks before loading state hooks)

Overall the migration is solid; just sanitize that error path.

@github-actions
Copy link
Copy Markdown
Contributor

Post-merge build verification passed

Both Go and frontend builds compiled successfully against merge commit 574cdb07ecbd178a2cd3c56a585c3f1c51c5db55.

@github-actions
Copy link
Copy Markdown
Contributor

✅ Post-Merge Verification: passed

Commit: 574cdb07ecbd178a2cd3c56a585c3f1c51c5db55
Specs run: Dashboard.spec.ts smoke.spec.ts
Report: https://github.com/kubestellar/console/actions/runs/25751891841

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated Pull request generated by AI copilot dco-signoff: yes Indicates the PR's author has signed the DCO. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tier/2-standard

1 participant