fix: add defensive error handling for API version detection

Ensure error messages are always strings before rendering to prevent
React error #310 (invalid React child - object).

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
2026-02-12 20:18:48 -05:00
parent 458ce7f2db
commit 329d030c1a
4 changed files with 20 additions and 10 deletions
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "headlamp-sealed-secrets",
"version": "0.2.8",
"version": "0.2.9",
"description": "Headlamp plugin for Bitnami Sealed Secrets - manage encrypted Kubernetes secrets",
"files": [
"dist",
@@ -32,14 +32,24 @@ export function VersionWarning({ autoDetect = true, showDetails = false }: Versi
setLoading(true);
setError(null);
const result = await SealedSecret.detectApiVersion();
try {
const result = await SealedSecret.detectApiVersion();
if (result.ok) {
setDetectedVersion(result.value);
setError(null);
} else if (result.ok === false) {
if (result.ok) {
setDetectedVersion(result.value);
setError(null);
} else if (result.ok === false) {
setDetectedVersion(null);
// Ensure error is always a string
const errorMessage = typeof result.error === 'string'
? result.error
: String(result.error);
setError(errorMessage);
}
} catch (e) {
// Catch any unexpected errors
setDetectedVersion(null);
setError(result.error);
setError(e instanceof Error ? e.message : String(e));
}
setLoading(false);
@@ -67,8 +77,8 @@ export function VersionWarning({ autoDetect = true, showDetails = false }: Versi
}>
<strong>API Version Detection Failed</strong>
<br />
{error}
{error.includes('not found') && (
{String(error)}
{String(error).includes('not found') && (
<>
<br />
<br />