diff --git a/CHANGELOG.md b/CHANGELOG.md index 36230e4..007485b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ verbatim as the body of the matching GitHub release. | Version | Date | Notes | |---|---|---| +| v0.2.5 | 2026-11-23 | [changelog/v0.2.5.md](changelog/v0.2.5.md) | | v0.2.4 | 2026-11-23 | [changelog/v0.2.4.md](changelog/v0.2.4.md) | | v0.2.3 | 2026-11-20 | [changelog/v0.2.3.md](changelog/v0.2.3.md) | | v0.2.2 | 2026-11-17 | [changelog/v0.2.2.md](changelog/v0.2.2.md) | diff --git a/changelog/v0.2.5.md b/changelog/v0.2.5.md new file mode 100644 index 0000000..a033766 --- /dev/null +++ b/changelog/v0.2.5.md @@ -0,0 +1,19 @@ +# v0.2.5 + +One fix: the GEMINI and VERTEX provider types could not be created. + +## Fixed + +- **Creating a `GEMINI` or `VERTEX` provider no longer fails.** V1's + `providers_type_check` constraint only allowed `OPENAI` and `ANTHROPIC`, and v0.2.3 + added the two new wire formats to the enum and the admin API without a migration for + the constraint. `POST /admin/providers` with `"type":"GEMINI"` (or `VERTEX`) answered + 500 `internal_error` on Postgres, and the console's Add Provider dialog failed the same + way. The new V21 migration finds the check constraint through `information_schema` + (its name differs between Postgres and H2) and replaces it with one that lists all four + types. +- `ProviderTypeConstraintTest` inserts one provider per wire format, so a constraint that + drifts behind the enum fails the build instead of production. + +Nothing else changed. v0.2.4's release notes cover the seeding change; deployments that +already run v0.2.4 only need this for native Gemini or Vertex. diff --git a/deploy/dokploy/README.md b/deploy/dokploy/README.md index cc0ed3e..53d041b 100644 --- a/deploy/dokploy/README.md +++ b/deploy/dokploy/README.md @@ -20,7 +20,7 @@ database. The console is always a plain Application. 3. Compose path: `deploy/dokploy/compose.yml`. 4. **Trigger Type: On Tag**, with auto-deploy enabled. The gateway is a production service; a pull request or a push to `Develop` must not restart it. A release tag - (`v0.2.4`) is the only thing that deploys — see "When it deploys" below. + (`v0.2.5`) is the only thing that deploys — see "When it deploys" below. 5. **Environment** (the compose file references all of these): ```bash diff --git a/docs/SPRING-AI.md b/docs/SPRING-AI.md index b51680e..cc0f14e 100644 --- a/docs/SPRING-AI.md +++ b/docs/SPRING-AI.md @@ -13,7 +13,7 @@ on Spring AI; the gateway never depends on it. io.github.an1ndra path-spring-ai - 0.2.4 + 0.2.5 ``` diff --git a/path-gateway/pom.xml b/path-gateway/pom.xml index 0dce331..55d924f 100644 --- a/path-gateway/pom.xml +++ b/path-gateway/pom.xml @@ -7,7 +7,7 @@ io.github.an1ndra path-parent - 0.2.4 + 0.2.5 ../pom.xml diff --git a/path-gateway/src/main/java/db/migration/V21__Provider_types.java b/path-gateway/src/main/java/db/migration/V21__Provider_types.java new file mode 100644 index 0000000..3147eeb --- /dev/null +++ b/path-gateway/src/main/java/db/migration/V21__Provider_types.java @@ -0,0 +1,58 @@ +package db.migration; + +import org.flywaydb.core.api.migration.BaseJavaMigration; +import org.flywaydb.core.api.migration.Context; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; + +/** + * Widens the provider `type` check constraint to the wire formats the code supports. + * + * V1 only knew OPENAI and ANTHROPIC; v0.2.3 added GEMINI and VERTEX to the enum without a + * migration, so creating either provider failed with a constraint violation on Postgres + * and H2 alike (the admin API answered 500). The constraint's name depends on the + * database (Postgres derives `providers_type_check`, H2 generates `CONSTRAINT_n`), so the + * migration finds it through information_schema instead of guessing. + */ +public class V21__Provider_types extends BaseJavaMigration { + + private static final String TABLE = "providers"; + + @Override + public void migrate(Context context) throws Exception { + Connection connection = context.getConnection(); + + for (String name : checkConstraints(connection)) { + try (Statement statement = connection.createStatement()) { + statement.execute("alter table " + TABLE + " drop constraint " + quote(name)); + } + } + + try (Statement statement = connection.createStatement()) { + statement.execute("alter table " + TABLE + " add constraint providers_type_check " + + "check (type in ('OPENAI', 'ANTHROPIC', 'GEMINI', 'VERTEX'))"); + } + } + + private List checkConstraints(Connection connection) throws Exception { + List names = new ArrayList<>(); + String sql = "select constraint_name from information_schema.table_constraints " + + "where lower(table_name) = '" + TABLE + "' and constraint_type = 'CHECK'"; + try (Statement statement = connection.createStatement(); + ResultSet rows = statement.executeQuery(sql)) { + while (rows.next()) { + names.add(rows.getString(1)); + } + } + return names; + } + + /** Identifiers are read from the catalog, not user input; still quote them safely. */ + private String quote(String identifier) { + return "\"" + identifier.replace("\"", "\"\"") + "\""; + } +} diff --git a/path-gateway/src/test/java/com/anindra/path/ProviderTypeConstraintTest.java b/path-gateway/src/test/java/com/anindra/path/ProviderTypeConstraintTest.java new file mode 100644 index 0000000..24a78d2 --- /dev/null +++ b/path-gateway/src/test/java/com/anindra/path/ProviderTypeConstraintTest.java @@ -0,0 +1,42 @@ +package com.anindra.path; + +import com.anindra.path.domain.Provider; +import com.anindra.path.domain.ProviderType; +import com.anindra.path.repo.ProviderRepository; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * V1's {@code providers_type_check} only allowed OPENAI and ANTHROPIC, so inserting a + * GEMINI or VERTEX provider failed with a constraint violation even though the enum and + * the admin API accepted both. V21 widens the constraint; this asserts every wire format + * the code knows about can actually be stored. + */ +@SpringBootTest(properties = { + "spring.datasource.url=jdbc:h2:mem:providertypes;MODE=PostgreSQL;DB_CLOSE_DELAY=-1", + "spring.jpa.hibernate.ddl-auto=validate", + "gateway.admin-token=test-admin", + "gateway.bootstrap-demo-key=false", + "gateway.master-key-path=./target/test-master.key" +}) +class ProviderTypeConstraintTest { + + @Autowired + private ProviderRepository providers; + + @Test + void everyWireFormatFitsTheCheckConstraint() { + for (ProviderType type : ProviderType.values()) { + String slug = "type-" + type.name().toLowerCase(); + providers.saveAndFlush( + new Provider(slug, type.name(), type, "https://example.test/v1")); + } + + assertThat(providers.findAll()) + .extracting(Provider::getType) + .containsExactlyInAnyOrder(ProviderType.values()); + } +} diff --git a/path-spring-ai/pom.xml b/path-spring-ai/pom.xml index 37cc133..2364f99 100644 --- a/path-spring-ai/pom.xml +++ b/path-spring-ai/pom.xml @@ -7,7 +7,7 @@ io.github.an1ndra path-parent - 0.2.4 + 0.2.5 ../pom.xml diff --git a/pom.xml b/pom.xml index a5f296d..4577072 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ io.github.an1ndra path-parent - 0.2.4 + 0.2.5 pom path-parent Build parent for Path, the provider-agnostic LLM gateway, and its Spring AI adapter