Skip to content

Commit e15c8ed

Browse files
jorbenclaude
andauthored
fix(updater): 🐛 sanitize update error details (#38)
* fix(updater): 🐛 sanitize update error details Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * ci: 👷 validate update manifests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b93e284 commit e15c8ed

3 files changed

Lines changed: 39 additions & 7 deletions

File tree

.github/workflows/release.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,28 @@ jobs:
124124
echo "Downloaded manifests:"
125125
find manifests -type f -name "*.yml" | sort
126126
127-
- name: Filter out builder-debug.yml and keep only latest manifests
127+
- name: Filter out builder-debug.yml
128128
run: |
129129
# Remove builder-debug.yml from manifests directory (exists in all platform artifacts)
130130
find manifests -name "builder-debug.yml" -delete
131+
131132
echo "Remaining manifests:"
132133
find manifests -type f -name "*.yml" | sort
133134
135+
- name: Validate required manifests
136+
run: |
137+
REQUIRED=(
138+
manifests/update-manifests-win/latest.yml
139+
manifests/update-manifests-mac/latest-mac.yml
140+
manifests/update-manifests-linux/latest-linux.yml
141+
)
142+
for file in "${REQUIRED[@]}"; do
143+
if [ ! -f "$file" ]; then
144+
echo "::error::Missing required update manifest: $file"
145+
exit 1
146+
fi
147+
done
148+
134149
- name: Upload update manifests to release
135150
uses: softprops/action-gh-release@v2
136151
with:

src/main/services/UpdateService.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,18 @@ class UpdateService {
6161
});
6262

6363
autoUpdater.on('error', (error) => {
64-
console.error('[UpdateService] Error:', error.message);
65-
this.sendStatus({ status: UpdateStatus.ERROR, error: error.message });
64+
const errorMessage = error instanceof Error ? error.message : String(error);
65+
const safeMessage =
66+
errorMessage.length > 200 ? `${errorMessage.slice(0, 200)}...` : errorMessage;
67+
const errorDetails = {
68+
message: safeMessage,
69+
name: error instanceof Error ? error.name : undefined,
70+
stack: error instanceof Error ? error.stack : undefined,
71+
code: (error as { code?: string | number }).code,
72+
statusCode: (error as { statusCode?: number }).statusCode,
73+
};
74+
console.error('[UpdateService] Error:', errorDetails);
75+
this.sendStatus({ status: UpdateStatus.ERROR, error: safeMessage });
6676
});
6777
}
6878

src/renderer/components/UpdateChecker.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,17 @@ const UpdateChecker: React.FC = () => {
110110

111111
case "error":
112112
return (
113-
<Space>
114-
<CloseCircleOutlined style={{ color: "#ff4d4f" }} />
115-
<Text type="danger">{t("update.error")}</Text>
116-
<Button onClick={handleCheckForUpdates}>{t("update.retry")}</Button>
113+
<Space direction="vertical">
114+
<Space>
115+
<CloseCircleOutlined style={{ color: "#ff4d4f" }} />
116+
<Text type="danger">{t("update.error")}</Text>
117+
<Button onClick={handleCheckForUpdates}>{t("update.retry")}</Button>
118+
</Space>
119+
{statusData.error && (
120+
<Text type="secondary" style={{ maxWidth: 420, wordBreak: 'break-word' }}>
121+
{statusData.error}
122+
</Text>
123+
)}
117124
</Space>
118125
);
119126

0 commit comments

Comments
 (0)