Skip to content

Commit 7967d6c

Browse files
authored
Merge pull request #1155 from Kiln-AI/KIL-471/create-run-config-error
fix: propagate actual errors from save_new_run_config
2 parents e5a3140 + 22c52b6 commit 7967d6c

File tree

5 files changed

+25
-45
lines changed

5 files changed

+25
-45
lines changed

app/web_ui/src/lib/ui/run_config_component/create_new_run_config_dialog.svelte

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,12 @@
5555
submitting = true
5656
try {
5757
save_config_error = null
58-
const saved_run_config = await run_config_component?.save_new_run_config()
59-
if (saved_run_config) {
60-
new_run_config_created?.(saved_run_config)
61-
close() // Only close on success
62-
} else {
63-
throw new Error("Resulting saved run config not found.")
58+
if (!run_config_component) {
59+
throw new Error("Run configuration component is not loaded")
6460
}
61+
const saved_run_config = await run_config_component.save_new_run_config()
62+
new_run_config_created?.(saved_run_config)
63+
close() // Only close on success
6564
} catch (e) {
6665
save_config_error = createKilnError(e)
6766
} finally {

app/web_ui/src/lib/ui/run_config_component/run_config_component.svelte

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
run_configs_by_task_composite_id,
1111
save_new_task_run_config,
1212
} from "$lib/stores/run_configs_store"
13-
import { createKilnError } from "$lib/utils/error_handlers"
1413
import { KilnError } from "$lib/utils/error_handlers"
1514
import type {
1615
RunConfigProperties,
@@ -47,7 +46,6 @@
4746
export let tools_selector_settings: Partial<ToolsSelectorSettings> = {}
4847
export let skills_selector_settings: Partial<SkillsSelectorSettings> = {}
4948
export let selected_run_config_id: string | null = null
50-
export let save_config_error: KilnError | null = null
5149
export let set_default_error: KilnError | null = null
5250
export let hide_prompt_selector: boolean = false
5351
export let hide_tools_selector: boolean = false
@@ -393,28 +391,22 @@
393391
}
394392
}
395393
396-
export async function save_new_run_config(): Promise<TaskRunConfig | null> {
394+
export async function save_new_run_config(): Promise<TaskRunConfig> {
397395
if (!current_task?.id) {
398-
return null
396+
throw new Error("Cannot save run config: no task selected")
399397
}
400-
try {
401-
save_config_error = null
402-
const saved_config = await save_new_task_run_config(
403-
project_id,
404-
current_task.id,
405-
run_options_as_run_config_properties(),
406-
run_config_name,
407-
)
408-
// Reload prompts to update the dropdown with the new static prompt that is made from saving a new run config
409-
await load_task_prompts(project_id, current_task.id, true)
410-
if (!saved_config || !saved_config.id) {
411-
throw new Error("Saved config id not found")
412-
}
413-
return saved_config
414-
} catch (e) {
415-
save_config_error = createKilnError(e)
398+
const saved_config = await save_new_task_run_config(
399+
project_id,
400+
current_task.id,
401+
run_options_as_run_config_properties(),
402+
run_config_name,
403+
)
404+
// Reload prompts to update the dropdown with the new static prompt that is made from saving a new run config
405+
await load_task_prompts(project_id, current_task.id, true)
406+
if (!saved_config || !saved_config.id) {
407+
throw new Error("Saved config id not found")
416408
}
417-
return null
409+
return saved_config
418410
}
419411
420412
async function get_selected_run_config(): Promise<
@@ -450,7 +442,6 @@
450442
}
451443
452444
export function clear_run_options_errors() {
453-
save_config_error = null
454445
set_default_error = null
455446
}
456447

app/web_ui/src/lib/ui/run_config_component/saved_run_configs_dropdown.svelte

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@
3636
export let project_id: string
3737
export let current_task: Task
3838
export let selected_run_config_id: string | null = null // This will be null until the default_run_config_id is set
39-
export let save_new_run_config: (() => Promise<TaskRunConfig | null>) | null =
40-
null
39+
export let save_new_run_config: (() => Promise<TaskRunConfig>) | null = null
4140
export let save_config_error: KilnError | null = null
4241
export let set_default_error: KilnError | null = null
4342
export let info_description: string = ""
@@ -248,7 +247,7 @@
248247
async function handle_save() {
249248
if (save_new_run_config) {
250249
const saved_run_config = await save_new_run_config()
251-
if (saved_run_config?.id) {
250+
if (saved_run_config.id) {
252251
selected_run_config_id = saved_run_config.id
253252
}
254253
}

app/web_ui/src/routes/(app)/optimize/[project_id]/[task_id]/run_config/create/+page.svelte

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,7 @@
6767
submitting = true
6868
try {
6969
save_config_error = null
70-
const saved_config = await run_config_component?.save_new_run_config()
71-
if (!saved_config) {
72-
throw new Error("Failed to save run config")
73-
}
70+
await run_config_component?.save_new_run_config()
7471
goto(`/optimize/${project_id}/${task_id}`)
7572
} catch (e) {
7673
save_config_error = createKilnError(e)

app/web_ui/src/routes/(app)/run/+page.svelte

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,11 @@
166166
}
167167
}
168168
169-
async function handle_save_new_run_config(): Promise<TaskRunConfig | null> {
170-
try {
171-
if (!run_config_component) {
172-
throw new Error("Run configuration component is not loaded")
173-
}
174-
return await run_config_component.save_new_run_config()
175-
} catch (e) {
176-
save_config_error = createKilnError(e)
169+
async function handle_save_new_run_config(): Promise<TaskRunConfig> {
170+
if (!run_config_component) {
171+
throw new Error("Run configuration component is not loaded")
177172
}
178-
return null
173+
return await run_config_component.save_new_run_config()
179174
}
180175
181176
function handle_input_change() {
@@ -228,7 +223,6 @@
228223
current_task={$current_task}
229224
requires_structured_output={!!$current_task.output_json_schema}
230225
bind:selected_run_config_id
231-
bind:save_config_error
232226
bind:set_default_error
233227
bind:selected_model_specific_run_config_id
234228
{pending_tool_id}

0 commit comments

Comments
 (0)