Summary
Duplicate-key errors from the repository layer are currently only detected for SQLite via isSQLiteUniqueConstraint. When running against other supported databases (e.g. PostgreSQL), a duplicate create operation surfaces as a generic failure instead of mapping to the appropriate sentinel error (e.g. ErrWebBrokerAPIExists, ErrWebSubAPIExists, etc.).
A cross-driver helper (e.g. isDuplicateKeyError) should be introduced that covers driver-specific error codes/messages (PostgreSQL code 23505, MySQL errno 1062, SQLite unique constraint, etc.) and used at all affected call sites.
Affected files
platform-api/src/internal/service/webbroker_api.go (line 154)
platform-api/src/internal/service/websub_api.go (line 153)
platform-api/src/internal/service/mcp.go (line 136)
platform-api/src/internal/service/llm.go (lines 148, 352, 643)
Note: gateway/gateway-controller/pkg/storage/factory.go already uses an abstracted isUniqueViolation function-field pattern, which can serve as a reference for the fix.
References
Summary
Duplicate-key errors from the repository layer are currently only detected for SQLite via
isSQLiteUniqueConstraint. When running against other supported databases (e.g. PostgreSQL), a duplicate create operation surfaces as a generic failure instead of mapping to the appropriate sentinel error (e.g.ErrWebBrokerAPIExists,ErrWebSubAPIExists, etc.).A cross-driver helper (e.g.
isDuplicateKeyError) should be introduced that covers driver-specific error codes/messages (PostgreSQL code23505, MySQL errno1062, SQLite unique constraint, etc.) and used at all affected call sites.Affected files
platform-api/src/internal/service/webbroker_api.go(line 154)platform-api/src/internal/service/websub_api.go(line 153)platform-api/src/internal/service/mcp.go(line 136)platform-api/src/internal/service/llm.go(lines 148, 352, 643)Note:
gateway/gateway-controller/pkg/storage/factory.goalready uses an abstractedisUniqueViolationfunction-field pattern, which can serve as a reference for the fix.References