wso2 / wso2/api-platform

Fix duplicate-key DB error handling to support all drivers (not only SQLite)

Open
#1,994 0 comments 0 reactions 1 assignee View on GitHub

@senthuran16 is already working on this.

Since May 20, 2026.

Dominant language
Go
Stars
71
Forks
111
Avg merge
1d 14h
Merged PRs (30d)
110

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.