Skip to content

🐛 Improve swallowed hook error handling#19304

Merged
clubanderson merged 5 commits into
mainfrom
scanner/fix-19300
Jun 20, 2026
Merged

🐛 Improve swallowed hook error handling#19304
clubanderson merged 5 commits into
mainfrom
scanner/fix-19300

Conversation

@clubanderson

Copy link
Copy Markdown
Collaborator

Fixes #19300

Improves Stellar network error propagation so init, batch refresh, and auto-solve failures update hook state, and keeps malformed localStorage cache handling non-fatal with a logged fallback.

Tests: npx vitest run src/hooks/__tests__/useStellarSource.test.tsx src/hooks/__tests__/useStackDiscovery.test.ts

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Hive Scanner <hive-scanner@kubestellar.local>
Copilot AI review requested due to automatic review settings June 20, 2026 14:37
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Jun 20, 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

netlify Bot commented Jun 20, 2026

Copy link
Copy Markdown

Deploy Preview for kubestellarconsole ready!

Name Link
🔨 Latest commit 45937b3
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/6a36ac6bb5bbdf0008862b87
😎 Deploy Preview https://deploy-preview-19304.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.

@github-actions

Copy link
Copy Markdown
Contributor

🐝 Hi @clubanderson! I'm kubestellar-hive[bot], an automation bot for this repo.

Trusted users — org members and contributors with write access — can mention @kubestellar-hive in a comment to trigger repo automation.
On issues, that mention queues an automated fix attempt. On pull requests, it records extra context for existing automation.
This is not an interactive Q&A bot, so mentions should be treated as requests for automation rather than a conversation.

Automation may take a moment to start, and follow-up happens through workflow activity rather than chat replies.

@github-actions github-actions Bot added the ai-generated Pull request generated by AI label Jun 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

👋 Hey @clubanderson — 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.

@kubestellar-prow kubestellar-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

✅ Test Coverage Check

All new source files in this PR have corresponding test files.

Checked web/src/hooks/ and web/src/components/ against origin/main.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to improve resilience in the frontend hooks layer by surfacing certain Stellar operational failures into hook state (via connectionError) and by ensuring malformed localStorage cache data for stack discovery remains non-fatal (with a warning + fallback). Build/lint are validated by CI on the PR.

Changes:

  • Add a small error-to-message helper and propagate selected Stellar failures into useStellarSource().connectionError.
  • Use safeJsonParse when loading the Stack Discovery cache so malformed JSON falls back safely.
  • Add/extend vitest coverage for Stellar error propagation and malformed stack cache handling.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
web/src/hooks/useStellarSource.ts Adds setOperationalError and updates refresh/batch/init/auto-solve paths to set connectionError on failures.
web/src/hooks/useStackDiscovery.ts Switches stack cache load to safeJsonParse and treats bad JSON as a non-fatal warning + fallback.
web/src/hooks/tests/useStellarSource.test.tsx Adds tests asserting connectionError updates when initial refresh, batch refresh, and auto-solve fail.
web/src/hooks/tests/useStackDiscovery.test.ts Adds a test asserting malformed stack cache logs a warning and doesn’t crash.

Comment on lines 143 to +155
const failures = results.filter(result => result.status === 'rejected')
if (failures.length > 0) console.warn('stellar: refreshState partial failure —', failures.length, 'of 7 calls failed')
}, [setNotifications])
if (failures.length === 0) {
setConnectionError(null)
return
}
console.warn('stellar: refreshState partial failure —', failures.length, 'of', STELLAR_REFRESH_REQUEST_COUNT, 'calls failed')
const firstFailure = failures[0]
setOperationalError(
firstFailure.status === 'rejected' ? firstFailure.reason : null,
failures.length === 1
? 'Failed to refresh Stellar state'
: `Failed to refresh Stellar state (${failures.length}/${STELLAR_REFRESH_REQUEST_COUNT} requests failed)`,
)
Comment on lines 326 to +334
try {
const cached = localStorage.getItem(CACHE_KEY)
if (!cached) return null
const parsed = JSON.parse(cached)
if (parsed.timestamp && parsed.stacks) {
const parsed = safeJsonParse<{ stacks?: LLMdStack[]; timestamp?: number } | null>(cached, null, 'stack cache')
if (parsed?.timestamp && parsed.stacks) {
return parsed
}
} catch {
// Ignore parse errors
// Ignore storage errors
The loadCachedStacks function returns `{ stacks: LLMdStack[]; timestamp: number } | null`
but safeJsonParse returns optional fields. After the truthiness guard, we must
explicitly construct the return object to satisfy TypeScript's type narrowing.

Signed-off-by: clubanderson <club.anderson@gmail.com>
@kubestellar-prow kubestellar-prow Bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 20, 2026
Signed-off-by: clubanderson <club.anderson@gmail.com>
@kubestellar-prow kubestellar-prow Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 20, 2026
@clubanderson clubanderson merged commit ffa2b94 into main Jun 20, 2026
33 of 40 checks passed
@kubestellar-prow kubestellar-prow Bot deleted the scanner/fix-19300 branch June 20, 2026 15:32
@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

@github-actions

Copy link
Copy Markdown
Contributor

✅ Post-Merge Verification: passed

Commit: ffa2b94e372d797f8228dc31051cc74d1a46bb26
Specs run: smoke.spec.ts
Report: https://github.com/kubestellar/console/actions/runs/27875634908

@github-actions

Copy link
Copy Markdown
Contributor

Post-merge build verification passed

Both Go and frontend builds compiled successfully against merge commit ffa2b94e372d797f8228dc31051cc74d1a46bb26.

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 dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tier/2-standard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Auto-QA] Swallowed errors and empty catch blocks

2 participants