fix(alerts): add AGENT_LIFECYCLE to condition_kind_enum + readable error toasts
Backend - V18 migration adds AGENT_LIFECYCLE to condition_kind_enum. Java ConditionKind enum shipped with this value but no Postgres migration extended the type, so any AGENT_LIFECYCLE rule insert failed with "invalid input value for enum condition_kind_enum". - ALTER TYPE ... ADD VALUE lives alone in its migration per Postgres constraint that the new value cannot be referenced in the same tx. - V18MigrationIT asserts the enum now contains all 7 kinds. Frontend - Add describeApiError(e) helper to unwrap openapi-fetch error bodies (Spring error JSON) into readable strings. String(e) on a plain object rendered "[object Object]" in toasts — the actual failure reason was hidden from the user. - Replace String(e) in all 13 toast descriptions across the alerting and outbound-connection mutation paths. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
-- V18 — Add AGENT_LIFECYCLE to condition_kind_enum.
|
||||
--
|
||||
-- The Java ConditionKind enum shipped AGENT_LIFECYCLE with the alerting
|
||||
-- branch, but no migration ever extended the Postgres type. Inserting a
|
||||
-- rule with conditionKind=AGENT_LIFECYCLE failed with
|
||||
-- ERROR: invalid input value for enum condition_kind_enum: "AGENT_LIFECYCLE"
|
||||
-- ALTER TYPE ... ADD VALUE must live alone in its migration — Postgres won't
|
||||
-- allow the new value to be referenced in the same transaction that adds it.
|
||||
|
||||
ALTER TYPE condition_kind_enum ADD VALUE IF NOT EXISTS 'AGENT_LIFECYCLE' AFTER 'AGENT_STATE';
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.cameleer.server.app.alerting.storage;
|
||||
|
||||
import com.cameleer.server.app.AbstractPostgresIT;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class V18MigrationIT extends AbstractPostgresIT {
|
||||
|
||||
@Test
|
||||
void condition_kind_enum_includes_agent_lifecycle() {
|
||||
var values = jdbcTemplate.queryForList("""
|
||||
SELECT unnest(enum_range(NULL::condition_kind_enum))::text AS v
|
||||
""", String.class);
|
||||
assertThat(values).contains("AGENT_LIFECYCLE");
|
||||
assertThat(values).containsExactlyInAnyOrder(
|
||||
"ROUTE_METRIC", "EXCHANGE_MATCH", "AGENT_STATE", "AGENT_LIFECYCLE",
|
||||
"DEPLOYMENT_STATE", "LOG_PATTERN", "JVM_METRIC");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user