Skip to content

Commit dc1902f

Browse files
Ricardo-M-Lclaude
andcommitted
fix(ui-tars): add HTTP status check in fetchPresetFromUrl and handle unknown operator type
1. fetchPresetFromUrl: check response.ok before parsing body. Without this, a 4xx/5xx response causes the YAML parser to choke on an error HTML page, producing a confusing error instead of a clear HTTP status. 2. runAgent switch: throw on unknown operator type instead of silently falling through. The operator variable is used with a non-null assertion (operator!) at line 202, so an unmatched case causes a runtime TypeError. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7986f5a commit dc1902f

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

apps/ui-tars/src/main/services/runAgent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export const runAgent = async (
161161
operatorType = 'browser';
162162
break;
163163
default:
164-
break;
164+
throw new Error(`Unsupported operator type: ${settings.operator}`);
165165
}
166166

167167
let modelVersion = getModelVersion(settings.vlmProvider);

apps/ui-tars/src/main/store/setting.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ export class SettingStore {
132132
public static async fetchPresetFromUrl(url: string): Promise<LocalStore> {
133133
try {
134134
const response = await fetch(url);
135+
if (!response.ok) {
136+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
137+
}
135138
const yamlContent = await response.text();
136139
return await this.importPresetFromText(yamlContent);
137140
} catch (error) {

0 commit comments

Comments
 (0)