fix(dashboard): template picker defensive fixes (handleApply + vacuous-truth)#1015
Open
yasinBursali wants to merge 2 commits intoLight-Heart-Labs:mainfrom
Open
Conversation
Collaborator
|
Audit follow-up: keep draft and rebase after #1003. The defensive TemplatePicker/error handling ideas are useful, but #1003 is now on |
getTemplateStatus used statuses.every(s => s === 'enabled'), which returns true for empty arrays (vacuous truth). Templates with services: [] were incorrectly classified 'applied' — invisible on the Extensions page (filter drops 'applied') and rendered as a disabled green 'Applied' card in the setup wizard. Early-return 'available' when services.length === 0 before the .every() check. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The silent .catch(() => ({})) swallowed malformed server responses
and fabricated an empty data object, showing a fake 'already active'
UI state when the backend actually returned something unparseable.
Drop the inline .catch so res.json() failures propagate to the
existing outer try/catch, which surfaces a user-visible
'Failed to apply template' error via setError.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
e7887cc to
479ec12
Compare
Contributor
Author
|
Rebased on current |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
✅ Rebased on current
main2026-04-28#1003 has merged. The PR diff is now exactly the 2-line "Our delta" view below:
lib/templates.js(+1 line) andTemplatePicker.jsx(1 line modified).What
Two small defensive fixes in template-related dashboard code:
lib/templates.jsgetTemplateStatus: add early-returnif (services.length === 0) return 'available'guarding against[].every(s => s === 'enabled')returning true (vacuous truth). Without this, templates withservices: []get misclassified as'applied'— silently hidden from the Extensions page (filter drops 'applied') and rendered as a disabled green "Applied" card in the setup wizard added by fix(dashboard,dashboard-api): sentinel-based setup wizard success detection #1003.TemplatePicker.jsxhandleApply: replaceconst data = await res.json().catch(() => ({}))withconst data = await res.json(). The silent.catch(() => ({}))swallowed malformed server responses and fabricated an empty data object → UI showed a fake "already active" state. The outertry/catchat line 159 already setssetError('Failed to apply template')— letting parse errors bubble there gives users a visible error state.Our delta
Two files, two lines:
dashboard/src/lib/templates.js:+ if (services.length === 0) return 'available'dashboard/src/components/TemplatePicker.jsx:- const data = await res.json().catch(() => ({}))→+ const data = await res.json()Testing
catch (err) { setError(...) }at TemplatePicker.jsx:159 shows a user-visible error path.every()check — empty-services templates now correctly return'available'Platform Impact